pdf-tsx 0.1.0
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/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/components/PDFSidebar.cjs +1 -0
- package/dist/cjs/components/PDFSidebar.module.cjs +1 -0
- package/dist/cjs/components/PDFViewer.cjs +1 -0
- package/dist/cjs/components/PDFViewer.module.cjs +1 -0
- package/dist/cjs/components/features/PDFAnnotations.cjs +1 -0
- package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -0
- package/dist/cjs/components/features/PDFChangeFile.cjs +1 -0
- package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -0
- package/dist/cjs/components/features/PDFNavigation.cjs +1 -0
- package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -0
- package/dist/cjs/components/features/PDFOutline.cjs +1 -0
- package/dist/cjs/components/features/PDFOutline.module.cjs +1 -0
- package/dist/cjs/components/features/PDFPageFit.cjs +1 -0
- package/dist/cjs/components/features/PDFPrintButton.cjs +1 -0
- package/dist/cjs/components/features/PDFRotationControl.cjs +1 -0
- package/dist/cjs/components/features/PDFSearch.cjs +1 -0
- package/dist/cjs/components/features/PDFSearch.module.cjs +1 -0
- package/dist/cjs/components/features/PDFSignatures.cjs +1 -0
- package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -0
- package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -0
- package/dist/cjs/components/features/PDFThumbnails.cjs +1 -0
- package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -0
- package/dist/cjs/components/features/PDFZoomControls.cjs +1 -0
- package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -0
- package/dist/cjs/components/ui/ToolbarButton.cjs +1 -0
- package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -0
- package/dist/cjs/components/ui/icons.cjs +1 -0
- package/dist/cjs/context/PDFViewerContext.cjs +1 -0
- package/dist/cjs/context/ThemeContext.cjs +1 -0
- package/dist/cjs/hooks/useAnnotationLayer.cjs +1 -0
- package/dist/cjs/hooks/useAnnotations.cjs +1 -0
- package/dist/cjs/hooks/useKeyboardShortcuts.cjs +1 -0
- package/dist/cjs/hooks/useOutline.cjs +1 -0
- package/dist/cjs/hooks/useScrollTracking.cjs +1 -0
- package/dist/cjs/hooks/useSignatures.cjs +1 -0
- package/dist/cjs/hooks/useTextLayer.cjs +1 -0
- package/dist/cjs/hooks/useTextSearch.cjs +1 -0
- package/dist/cjs/hooks/useThumbnails.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/node_modules/react/cjs/react-compiler-runtime.development.cjs +5 -0
- package/dist/cjs/node_modules/react/cjs/react-compiler-runtime.production.cjs +1 -0
- package/dist/cjs/node_modules/react/compiler-runtime.cjs +1 -0
- package/dist/cjs/pdf-tsx.css +2 -0
- package/dist/cjs/theme.cjs +1 -0
- package/dist/cjs/utils/url.cjs +1 -0
- package/dist/cjs/vite.svg +1 -0
- package/dist/components/PDFSidebar.d.ts +11 -0
- package/dist/components/PDFViewer.d.ts +10 -0
- package/dist/components/features/PDFAnnotations.d.ts +1 -0
- package/dist/components/features/PDFChangeFile.d.ts +6 -0
- package/dist/components/features/PDFDownloadButton.d.ts +6 -0
- package/dist/components/features/PDFNavigation.d.ts +7 -0
- package/dist/components/features/PDFOutline.d.ts +1 -0
- package/dist/components/features/PDFPageFit.d.ts +7 -0
- package/dist/components/features/PDFPrintButton.d.ts +6 -0
- package/dist/components/features/PDFRotationControl.d.ts +6 -0
- package/dist/components/features/PDFSearch.d.ts +9 -0
- package/dist/components/features/PDFSignatures.d.ts +1 -0
- package/dist/components/features/PDFThemeToggle.d.ts +7 -0
- package/dist/components/features/PDFThumbnails.d.ts +1 -0
- package/dist/components/features/PDFZoomControls.d.ts +7 -0
- package/dist/components/ui/ToolbarButton.d.ts +6 -0
- package/dist/components/ui/icons.d.ts +20 -0
- package/dist/context/PDFViewerContext.d.ts +25 -0
- package/dist/context/ThemeContext.d.ts +12 -0
- package/dist/es/_virtual/_rolldown/runtime.js +7 -0
- package/dist/es/components/PDFSidebar.js +43 -0
- package/dist/es/components/PDFSidebar.module.js +11 -0
- package/dist/es/components/PDFViewer.js +263 -0
- package/dist/es/components/PDFViewer.module.js +16 -0
- package/dist/es/components/features/PDFAnnotations.js +94 -0
- package/dist/es/components/features/PDFAnnotations.module.js +14 -0
- package/dist/es/components/features/PDFChangeFile.js +36 -0
- package/dist/es/components/features/PDFDownloadButton.js +23 -0
- package/dist/es/components/features/PDFNavigation.js +71 -0
- package/dist/es/components/features/PDFNavigation.module.js +7 -0
- package/dist/es/components/features/PDFOutline.js +101 -0
- package/dist/es/components/features/PDFOutline.module.js +9 -0
- package/dist/es/components/features/PDFPageFit.js +43 -0
- package/dist/es/components/features/PDFPrintButton.js +26 -0
- package/dist/es/components/features/PDFRotationControl.js +22 -0
- package/dist/es/components/features/PDFSearch.js +77 -0
- package/dist/es/components/features/PDFSearch.module.js +8 -0
- package/dist/es/components/features/PDFSignatures.js +133 -0
- package/dist/es/components/features/PDFSignatures.module.js +18 -0
- package/dist/es/components/features/PDFThemeToggle.js +17 -0
- package/dist/es/components/features/PDFThumbnails.js +40 -0
- package/dist/es/components/features/PDFThumbnails.module.js +11 -0
- package/dist/es/components/features/PDFZoomControls.js +47 -0
- package/dist/es/components/features/PDFZoomControls.module.js +3 -0
- package/dist/es/components/ui/ToolbarButton.js +16 -0
- package/dist/es/components/ui/ToolbarButton.module.js +6 -0
- package/dist/es/components/ui/icons.js +28 -0
- package/dist/es/context/PDFViewerContext.js +11 -0
- package/dist/es/context/ThemeContext.js +43 -0
- package/dist/es/hooks/useAnnotationLayer.js +71 -0
- package/dist/es/hooks/useAnnotations.js +44 -0
- package/dist/es/hooks/useKeyboardShortcuts.js +54 -0
- package/dist/es/hooks/useOutline.js +20 -0
- package/dist/es/hooks/useScrollTracking.js +46 -0
- package/dist/es/hooks/useSignatures.js +45 -0
- package/dist/es/hooks/useTextLayer.js +42 -0
- package/dist/es/hooks/useTextSearch.js +53 -0
- package/dist/es/hooks/useThumbnails.js +31 -0
- package/dist/es/index.js +16 -0
- package/dist/es/node_modules/react/cjs/react-compiler-runtime.development.js +14 -0
- package/dist/es/node_modules/react/cjs/react-compiler-runtime.production.js +11 -0
- package/dist/es/node_modules/react/compiler-runtime.js +10 -0
- package/dist/es/pdf-tsx.css +2 -0
- package/dist/es/theme.js +67 -0
- package/dist/es/utils/url.js +11 -0
- package/dist/es/vite.svg +1 -0
- package/dist/hooks/useAnnotationLayer.d.ts +20 -0
- package/dist/hooks/useAnnotations.d.ts +20 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +11 -0
- package/dist/hooks/useOutline.d.ts +14 -0
- package/dist/hooks/useScrollTracking.d.ts +14 -0
- package/dist/hooks/useSignatures.d.ts +17 -0
- package/dist/hooks/useTextLayer.d.ts +10 -0
- package/dist/hooks/useTextSearch.d.ts +12 -0
- package/dist/hooks/useThumbnails.d.ts +9 -0
- package/dist/index.d.ts +15 -0
- package/dist/pdf-tsx.cjs.js +5 -0
- package/dist/pdf-tsx.css +2 -0
- package/dist/pdf-tsx.es.js +2637 -0
- package/dist/theme.d.ts +24 -0
- package/dist/utils/url.d.ts +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
|
|
2
|
+
import { require_compiler_runtime as t } from "../../node_modules/react/compiler-runtime.js";
|
|
3
|
+
import { ToolbarButton as n } from "../ui/ToolbarButton.js";
|
|
4
|
+
import r from "./PDFZoomControls.module.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/features/PDFZoomControls.tsx
|
|
8
|
+
var s = t();
|
|
9
|
+
function c(t) {
|
|
10
|
+
let c = (0, s.c)(18), { zoomOutIcon: d, zoomInIcon: f } = t, { zoom: p, setZoom: m } = e(), h;
|
|
11
|
+
c[0] === m ? h = c[1] : (h = () => m(u), c[0] = m, c[1] = h);
|
|
12
|
+
let g;
|
|
13
|
+
c[2] !== h || c[3] !== d ? (g = /* @__PURE__ */ a(n, {
|
|
14
|
+
onClick: h,
|
|
15
|
+
title: "Riduci zoom",
|
|
16
|
+
children: d
|
|
17
|
+
}), c[2] = h, c[3] = d, c[4] = g) : g = c[4];
|
|
18
|
+
let _;
|
|
19
|
+
c[5] === p ? _ = c[6] : (_ = Math.round(p * 100), c[5] = p, c[6] = _);
|
|
20
|
+
let v;
|
|
21
|
+
c[7] === _ ? v = c[8] : (v = /* @__PURE__ */ o("span", {
|
|
22
|
+
className: r.zoomLabel,
|
|
23
|
+
children: [_, "%"]
|
|
24
|
+
}), c[7] = _, c[8] = v);
|
|
25
|
+
let y;
|
|
26
|
+
c[9] === m ? y = c[10] : (y = () => m(l), c[9] = m, c[10] = y);
|
|
27
|
+
let b;
|
|
28
|
+
c[11] !== y || c[12] !== f ? (b = /* @__PURE__ */ a(n, {
|
|
29
|
+
onClick: y,
|
|
30
|
+
title: "Aumenta zoom",
|
|
31
|
+
children: f
|
|
32
|
+
}), c[11] = y, c[12] = f, c[13] = b) : b = c[13];
|
|
33
|
+
let x;
|
|
34
|
+
return c[14] !== g || c[15] !== v || c[16] !== b ? (x = /* @__PURE__ */ o(i, { children: [
|
|
35
|
+
g,
|
|
36
|
+
v,
|
|
37
|
+
b
|
|
38
|
+
] }), c[14] = g, c[15] = v, c[16] = b, c[17] = x) : x = c[17], x;
|
|
39
|
+
}
|
|
40
|
+
function l(e) {
|
|
41
|
+
return Math.min(e + .2, 3);
|
|
42
|
+
}
|
|
43
|
+
function u(e) {
|
|
44
|
+
return Math.max(e - .2, .2);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { c as PDFZoomControls };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import t from "./ToolbarButton.module.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/ui/ToolbarButton.tsx
|
|
5
|
+
var r = e();
|
|
6
|
+
function i(e) {
|
|
7
|
+
let i = (0, r.c)(7), a, o, s;
|
|
8
|
+
i[0] === e ? (a = i[1], o = i[2], s = i[3]) : ({$primary: a, className: o, ...s} = e, i[0] = e, i[1] = a, i[2] = o, i[3] = s);
|
|
9
|
+
let c = a ? `${t.btn} ${t.primary}` : t.btn, l = o ? `${c} ${o}` : c, u;
|
|
10
|
+
return i[4] !== s || i[5] !== l ? (u = /* @__PURE__ */ n("button", {
|
|
11
|
+
className: l,
|
|
12
|
+
...s
|
|
13
|
+
}), i[4] = s, i[5] = l, i[6] = u) : u = i[6], u;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as ToolbarButton };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/ui/icons.tsx
|
|
5
|
+
var n = e(), r = (e, n = 16) => /* @__PURE__ */ t("svg", {
|
|
6
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
7
|
+
width: n,
|
|
8
|
+
height: n,
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
fill: "none",
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeWidth: 2,
|
|
13
|
+
strokeLinecap: "round",
|
|
14
|
+
strokeLinejoin: "round",
|
|
15
|
+
children: e
|
|
16
|
+
}), i = (e) => {
|
|
17
|
+
let i = (0, n.c)(3), { size: a } = e, o;
|
|
18
|
+
i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ t("polyline", { points: "9 18 15 12 9 6" }), i[0] = o) : o = i[0];
|
|
19
|
+
let s;
|
|
20
|
+
return i[1] === a ? s = i[2] : (s = r(o, a), i[1] = a, i[2] = s), s;
|
|
21
|
+
}, a = (e) => {
|
|
22
|
+
let i = (0, n.c)(3), { size: a } = e, o;
|
|
23
|
+
i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ t("polyline", { points: "6 9 12 15 18 9" }), i[0] = o) : o = i[0];
|
|
24
|
+
let s;
|
|
25
|
+
return i[1] === a ? s = i[2] : (s = r(o, a), i[1] = a, i[2] = s), s;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { a as IconChevronDown, i as IconChevronRight };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "react";
|
|
2
|
+
import "pdfjs-dist";
|
|
3
|
+
//#region src/context/PDFViewerContext.ts
|
|
4
|
+
var n = e(null);
|
|
5
|
+
function r() {
|
|
6
|
+
let e = t(n);
|
|
7
|
+
if (!e) throw Error("usePDFViewer must be used inside <PDFViewer>");
|
|
8
|
+
return e;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n as PDFViewerContext, r as usePDFViewer };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import { darkTheme as t, lightTheme as n, themeToCssVars as r } from "../theme.js";
|
|
3
|
+
import { createContext as i, useContext as a, useState as o } from "react";
|
|
4
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
5
|
+
//#region src/context/ThemeContext.tsx
|
|
6
|
+
var c = e(), l = i(null);
|
|
7
|
+
function u(e) {
|
|
8
|
+
let i = (0, c.c)(14), { children: a } = e, [u, f] = o(!0), p = u ? t : n, m;
|
|
9
|
+
i[0] === p ? m = i[1] : (m = r(p), i[0] = p, i[1] = m);
|
|
10
|
+
let h = m, g;
|
|
11
|
+
i[2] === Symbol.for("react.memo_cache_sentinel") ? (g = () => f(d), i[2] = g) : g = i[2];
|
|
12
|
+
let _;
|
|
13
|
+
i[3] !== u || i[4] !== p ? (_ = {
|
|
14
|
+
isDark: u,
|
|
15
|
+
toggleTheme: g,
|
|
16
|
+
theme: p
|
|
17
|
+
}, i[3] = u, i[4] = p, i[5] = _) : _ = i[5];
|
|
18
|
+
let v = h, y;
|
|
19
|
+
i[6] === v ? y = i[7] : (y = {
|
|
20
|
+
...v,
|
|
21
|
+
display: "contents"
|
|
22
|
+
}, i[6] = v, i[7] = y);
|
|
23
|
+
let b;
|
|
24
|
+
i[8] !== a || i[9] !== y ? (b = /* @__PURE__ */ s("div", {
|
|
25
|
+
style: y,
|
|
26
|
+
children: a
|
|
27
|
+
}), i[8] = a, i[9] = y, i[10] = b) : b = i[10];
|
|
28
|
+
let x;
|
|
29
|
+
return i[11] !== _ || i[12] !== b ? (x = /* @__PURE__ */ s(l.Provider, {
|
|
30
|
+
value: _,
|
|
31
|
+
children: b
|
|
32
|
+
}), i[11] = _, i[12] = b, i[13] = x) : x = i[13], x;
|
|
33
|
+
}
|
|
34
|
+
function d(e) {
|
|
35
|
+
return !e;
|
|
36
|
+
}
|
|
37
|
+
function f() {
|
|
38
|
+
let e = a(l);
|
|
39
|
+
if (!e) throw Error("useTheme must be used inside <ThemeProvider>");
|
|
40
|
+
return e;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { u as ThemeProvider, f as useTheme };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import { isSafeUrl as t } from "../utils/url.js";
|
|
3
|
+
import { useEffect as n, useState as r } from "react";
|
|
4
|
+
import "pdfjs-dist";
|
|
5
|
+
//#region src/hooks/useAnnotationLayer.ts
|
|
6
|
+
var i = e();
|
|
7
|
+
function a(e) {
|
|
8
|
+
let a = (0, i.c)(15), { pdf: o, zoom: s, rotation: c, numPages: l, goToPage: u } = e, d;
|
|
9
|
+
a[0] === Symbol.for("react.memo_cache_sentinel") ? (d = [], a[0] = d) : d = a[0];
|
|
10
|
+
let [f, p] = r(d), m, h;
|
|
11
|
+
a[1] !== l || a[2] !== o || a[3] !== c || a[4] !== s ? (m = () => {
|
|
12
|
+
if (!o) return;
|
|
13
|
+
let e = !1;
|
|
14
|
+
return (async () => {
|
|
15
|
+
p([]);
|
|
16
|
+
let t = [];
|
|
17
|
+
for (let n = 1; n <= l && !e; n++) {
|
|
18
|
+
let e = await o.getPage(n), r = e.getViewport({
|
|
19
|
+
scale: s,
|
|
20
|
+
rotation: c
|
|
21
|
+
}), i = await e.getAnnotations();
|
|
22
|
+
for (let e of i) {
|
|
23
|
+
if (e.subtype !== "Link" || !e.rect) continue;
|
|
24
|
+
let i = e.rect, [a, o, s, c] = r.convertToViewportRectangle(i);
|
|
25
|
+
t.push({
|
|
26
|
+
page: n,
|
|
27
|
+
x: Math.min(a, s),
|
|
28
|
+
y: Math.min(o, c),
|
|
29
|
+
width: Math.abs(s - a),
|
|
30
|
+
height: Math.abs(c - o),
|
|
31
|
+
url: e.url,
|
|
32
|
+
dest: e.dest,
|
|
33
|
+
newWindow: e.newWindow
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
e || p(t);
|
|
38
|
+
})(), () => {
|
|
39
|
+
e = !0;
|
|
40
|
+
};
|
|
41
|
+
}, h = [
|
|
42
|
+
o,
|
|
43
|
+
s,
|
|
44
|
+
c,
|
|
45
|
+
l
|
|
46
|
+
], a[1] = l, a[2] = o, a[3] = c, a[4] = s, a[5] = m, a[6] = h) : (m = a[5], h = a[6]), n(m, h);
|
|
47
|
+
let g;
|
|
48
|
+
a[7] !== u || a[8] !== o ? (g = async (e) => {
|
|
49
|
+
if (e.url) {
|
|
50
|
+
if (!t(e.url)) return;
|
|
51
|
+
window.open(e.url, "_blank", "noopener,noreferrer");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (e.dest && o) {
|
|
55
|
+
let t = null;
|
|
56
|
+
if (typeof e.dest == "string" ? t = await o.getDestination(e.dest) : Array.isArray(e.dest) && (t = e.dest), !t) return;
|
|
57
|
+
u(await o.getPageIndex(t[0]) + 1);
|
|
58
|
+
}
|
|
59
|
+
}, a[7] = u, a[8] = o, a[9] = g) : g = a[9];
|
|
60
|
+
let _ = g, v;
|
|
61
|
+
if (a[10] !== _ || a[11] !== f) {
|
|
62
|
+
let e;
|
|
63
|
+
a[13] === _ ? e = a[14] : (e = (e) => ({
|
|
64
|
+
...e,
|
|
65
|
+
_handleClick: _.bind(null, e)
|
|
66
|
+
}), a[13] = _, a[14] = e), v = f.map(e), a[10] = _, a[11] = f, a[12] = v;
|
|
67
|
+
} else v = a[12];
|
|
68
|
+
return v;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { a as useAnnotationLayer };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
import "pdfjs-dist";
|
|
3
|
+
//#region src/hooks/useAnnotations.ts
|
|
4
|
+
var n = new Set([
|
|
5
|
+
"Widget",
|
|
6
|
+
"Link",
|
|
7
|
+
"Popup"
|
|
8
|
+
]);
|
|
9
|
+
function r({ pdf: r }) {
|
|
10
|
+
let [i, a] = t([]), [o, s] = t(!1);
|
|
11
|
+
return e(() => {
|
|
12
|
+
r && (async () => {
|
|
13
|
+
s(!0);
|
|
14
|
+
try {
|
|
15
|
+
let e = [];
|
|
16
|
+
for (let t = 1; t <= r.numPages; t++) {
|
|
17
|
+
let i = await (await r.getPage(t)).getAnnotations();
|
|
18
|
+
for (let r of i) {
|
|
19
|
+
let i = r.subtype;
|
|
20
|
+
n.has(i) || e.push({
|
|
21
|
+
id: r.id,
|
|
22
|
+
page: t,
|
|
23
|
+
subtype: i,
|
|
24
|
+
contents: r.contents,
|
|
25
|
+
title: r.title,
|
|
26
|
+
color: r.color,
|
|
27
|
+
rect: r.rect
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
a(e);
|
|
32
|
+
} catch {
|
|
33
|
+
a([]);
|
|
34
|
+
} finally {
|
|
35
|
+
s(!1);
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
38
|
+
}, [r]), {
|
|
39
|
+
annotations: i,
|
|
40
|
+
loading: o
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { r as useAnnotations };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import { useEffect as t } from "react";
|
|
3
|
+
import "pdfjs-dist";
|
|
4
|
+
//#region src/hooks/useKeyboardShortcuts.ts
|
|
5
|
+
var n = e();
|
|
6
|
+
function r(e) {
|
|
7
|
+
let r = (0, n.c)(13), { pdf: s, currentPage: c, numPages: l, goToPage: u, setZoom: d, setRotation: f } = e, p;
|
|
8
|
+
r[0] !== c || r[1] !== u || r[2] !== s || r[3] !== f || r[4] !== d ? (p = () => {
|
|
9
|
+
if (!s) return;
|
|
10
|
+
let e = (e) => {
|
|
11
|
+
let t = e.target.tagName;
|
|
12
|
+
if (!(t === "INPUT" || t === "TEXTAREA")) bb13: switch (e.key) {
|
|
13
|
+
case "ArrowLeft":
|
|
14
|
+
case "ArrowUp":
|
|
15
|
+
e.preventDefault(), u(c - 1);
|
|
16
|
+
break bb13;
|
|
17
|
+
case "ArrowRight":
|
|
18
|
+
case "ArrowDown":
|
|
19
|
+
e.preventDefault(), u(c + 1);
|
|
20
|
+
break bb13;
|
|
21
|
+
case "+":
|
|
22
|
+
case "=":
|
|
23
|
+
e.preventDefault(), d(o);
|
|
24
|
+
break bb13;
|
|
25
|
+
case "-":
|
|
26
|
+
e.preventDefault(), d(a);
|
|
27
|
+
break bb13;
|
|
28
|
+
case "r":
|
|
29
|
+
case "R": e.preventDefault(), f(i);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
33
|
+
}, r[0] = c, r[1] = u, r[2] = s, r[3] = f, r[4] = d, r[5] = p) : p = r[5];
|
|
34
|
+
let m;
|
|
35
|
+
r[6] !== c || r[7] !== u || r[8] !== l || r[9] !== s || r[10] !== f || r[11] !== d ? (m = [
|
|
36
|
+
s,
|
|
37
|
+
c,
|
|
38
|
+
l,
|
|
39
|
+
u,
|
|
40
|
+
d,
|
|
41
|
+
f
|
|
42
|
+
], r[6] = c, r[7] = u, r[8] = l, r[9] = s, r[10] = f, r[11] = d, r[12] = m) : m = r[12], t(p, m);
|
|
43
|
+
}
|
|
44
|
+
function i(e) {
|
|
45
|
+
return (e + 90) % 360;
|
|
46
|
+
}
|
|
47
|
+
function a(e) {
|
|
48
|
+
return Math.max(e - .2, .2);
|
|
49
|
+
}
|
|
50
|
+
function o(e) {
|
|
51
|
+
return Math.min(e + .2, 3);
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { r as useKeyboardShortcuts };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import "pdfjs-dist";
|
|
4
|
+
//#region src/hooks/useOutline.ts
|
|
5
|
+
var r = e();
|
|
6
|
+
function i(e) {
|
|
7
|
+
let i = (0, r.c)(7), { pdf: a } = e, o;
|
|
8
|
+
i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = [], i[0] = o) : o = i[0];
|
|
9
|
+
let [s, c] = n(o), [l, u] = n(!1), d, f;
|
|
10
|
+
i[1] === a ? (d = i[2], f = i[3]) : (d = () => {
|
|
11
|
+
a && (u(!0), a.getOutline().then((e) => c(e ?? [])).catch(() => c([])).finally(() => u(!1)));
|
|
12
|
+
}, f = [a], i[1] = a, i[2] = d, i[3] = f), t(d, f);
|
|
13
|
+
let p;
|
|
14
|
+
return i[4] !== l || i[5] !== s ? (p = {
|
|
15
|
+
outline: s,
|
|
16
|
+
loading: l
|
|
17
|
+
}, i[4] = l, i[5] = s, i[6] = p) : p = i[6], p;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { i as useOutline };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import "pdfjs-dist";
|
|
4
|
+
//#region src/hooks/useScrollTracking.ts
|
|
5
|
+
var r = e(), i = 10;
|
|
6
|
+
function a(e) {
|
|
7
|
+
let a = (0, r.c)(16), { pdf: o, numPages: s, zoom: c, rotation: l, containerRef: u, canvasRefs: d } = e, [f, p] = n(1), m;
|
|
8
|
+
a[0] !== d || a[1] !== u ? (m = () => {
|
|
9
|
+
let e = u.current;
|
|
10
|
+
if (!e) return;
|
|
11
|
+
let t = () => {
|
|
12
|
+
let t = e.getBoundingClientRect().top, n = d.current;
|
|
13
|
+
for (let e = 0; e < n.length; e++) {
|
|
14
|
+
let r = n[e];
|
|
15
|
+
r && (r.parentElement ?? r).getBoundingClientRect().top - t <= 150 && p(e + 1);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
|
|
19
|
+
}, a[0] = d, a[1] = u, a[2] = m) : m = a[2];
|
|
20
|
+
let h;
|
|
21
|
+
a[3] !== d || a[4] !== u || a[5] !== o || a[6] !== l || a[7] !== c ? (h = [
|
|
22
|
+
o,
|
|
23
|
+
c,
|
|
24
|
+
l,
|
|
25
|
+
u,
|
|
26
|
+
d
|
|
27
|
+
], a[3] = d, a[4] = u, a[5] = o, a[6] = l, a[7] = c, a[8] = h) : h = a[8], t(m, h);
|
|
28
|
+
let g;
|
|
29
|
+
a[9] !== d || a[10] !== u || a[11] !== s ? (g = (e) => {
|
|
30
|
+
let t = Math.min(Math.max(e, 1), s), n = d.current[t - 1], r = u.current;
|
|
31
|
+
if (n && r) {
|
|
32
|
+
let e = (n.parentElement ?? n).getBoundingClientRect().top, a = r.getBoundingClientRect().top, o = r.scrollTop + (e - a) - i;
|
|
33
|
+
r.scrollTo({
|
|
34
|
+
top: o,
|
|
35
|
+
behavior: "smooth"
|
|
36
|
+
}), p(t);
|
|
37
|
+
}
|
|
38
|
+
}, a[9] = d, a[10] = u, a[11] = s, a[12] = g) : g = a[12];
|
|
39
|
+
let _ = g, v;
|
|
40
|
+
return a[13] !== f || a[14] !== _ ? (v = {
|
|
41
|
+
currentPage: f,
|
|
42
|
+
goToPage: _
|
|
43
|
+
}, a[13] = f, a[14] = _, a[15] = v) : v = a[15], v;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { a as useScrollTracking };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
import "pdfjs-dist";
|
|
3
|
+
//#region src/hooks/useSignatures.ts
|
|
4
|
+
function n({ pdf: n }) {
|
|
5
|
+
let [r, i] = t([]), [a, o] = t(!1);
|
|
6
|
+
return e(() => {
|
|
7
|
+
n && (async () => {
|
|
8
|
+
o(!0);
|
|
9
|
+
try {
|
|
10
|
+
let e = await n.getFieldObjects();
|
|
11
|
+
if (!e) {
|
|
12
|
+
i([]);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let t = [];
|
|
16
|
+
for (let [n, r] of Object.entries(e)) for (let e of r) e.type === "signature" && t.push({
|
|
17
|
+
fieldName: n,
|
|
18
|
+
page: e.page ?? 0
|
|
19
|
+
});
|
|
20
|
+
i(await Promise.all(t.map(async ({ fieldName: e, page: t }) => {
|
|
21
|
+
let r = (await (await n.getPage(t + 1)).getAnnotations()).find((t) => t.fieldType === "Sig" && t.fieldName === e), i = !!r?.hasAppearance, a = r?.fieldValue, o = typeof a == "object" && a ? a : void 0;
|
|
22
|
+
return {
|
|
23
|
+
fieldName: e,
|
|
24
|
+
page: t + 1,
|
|
25
|
+
signed: i,
|
|
26
|
+
rect: r?.rect,
|
|
27
|
+
signerName: o?.name,
|
|
28
|
+
signDate: o?.date,
|
|
29
|
+
reason: o?.reason,
|
|
30
|
+
location: o?.location
|
|
31
|
+
};
|
|
32
|
+
})));
|
|
33
|
+
} catch {
|
|
34
|
+
i([]);
|
|
35
|
+
} finally {
|
|
36
|
+
o(!1);
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
}, [n]), {
|
|
40
|
+
signatures: r,
|
|
41
|
+
loading: a
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { n as useSignatures };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { useEffect as t, useRef as n } from "react";
|
|
4
|
+
import * as r from "pdfjs-dist";
|
|
5
|
+
//#region src/hooks/useTextLayer.ts
|
|
6
|
+
var i = e();
|
|
7
|
+
function a(e) {
|
|
8
|
+
let a = (0, i.c)(8), { pdf: o, zoom: s, rotation: c, numPages: l, canvasRefs: u } = e, d;
|
|
9
|
+
a[0] === Symbol.for("react.memo_cache_sentinel") ? (d = [], a[0] = d) : d = a[0];
|
|
10
|
+
let f = n(d), p, m;
|
|
11
|
+
return a[1] !== u || a[2] !== l || a[3] !== o || a[4] !== c || a[5] !== s ? (p = () => {
|
|
12
|
+
if (!o) return;
|
|
13
|
+
let e = !1;
|
|
14
|
+
return (async () => {
|
|
15
|
+
for (let t = 1; t <= l && !e; t++) {
|
|
16
|
+
let n = f.current[t - 1], i = u.current[t - 1];
|
|
17
|
+
if (!n || !i) continue;
|
|
18
|
+
n.replaceChildren();
|
|
19
|
+
let a = await o.getPage(t), l = a.getViewport({
|
|
20
|
+
scale: s,
|
|
21
|
+
rotation: c
|
|
22
|
+
}), d = await a.getTextContent();
|
|
23
|
+
if (e) break;
|
|
24
|
+
n.style.width = `${l.width}px`, n.style.height = `${l.height}px`, await new r.TextLayer({
|
|
25
|
+
textContentSource: d,
|
|
26
|
+
container: n,
|
|
27
|
+
viewport: l
|
|
28
|
+
}).render();
|
|
29
|
+
}
|
|
30
|
+
})(), () => {
|
|
31
|
+
e = !0;
|
|
32
|
+
};
|
|
33
|
+
}, m = [
|
|
34
|
+
o,
|
|
35
|
+
s,
|
|
36
|
+
c,
|
|
37
|
+
l,
|
|
38
|
+
u
|
|
39
|
+
], a[1] = u, a[2] = l, a[3] = o, a[4] = c, a[5] = s, a[6] = p, a[7] = m) : (p = a[6], m = a[7]), t(p, m), f;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { a as useTextLayer };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import "pdfjs-dist";
|
|
4
|
+
//#region src/hooks/useTextSearch.ts
|
|
5
|
+
var r = e();
|
|
6
|
+
function i(e) {
|
|
7
|
+
let i = (0, r.c)(8), { pdf: a, query: o } = e, s;
|
|
8
|
+
i[0] === Symbol.for("react.memo_cache_sentinel") ? (s = [], i[0] = s) : s = i[0];
|
|
9
|
+
let [c, l] = n(s), [u, d] = n(!1), f, p;
|
|
10
|
+
i[1] !== a || i[2] !== o ? (f = () => {
|
|
11
|
+
let e = o.trim().toLowerCase();
|
|
12
|
+
if (!a || !e) {
|
|
13
|
+
l([]);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let t = !1;
|
|
17
|
+
return (async () => {
|
|
18
|
+
d(!0);
|
|
19
|
+
let n = [];
|
|
20
|
+
for (let r = 1; r <= a.numPages && !t; r++) {
|
|
21
|
+
let t = await (await a.getPage(r)).getTextContent();
|
|
22
|
+
for (let i of t.items) {
|
|
23
|
+
if (!("str" in i)) continue;
|
|
24
|
+
let t = i.str.toLowerCase(), a = t.indexOf(e);
|
|
25
|
+
if (a === -1) continue;
|
|
26
|
+
let o = i.transform, s = o[0], c = o[4], l = o[5], u = i.width, d = i.height, f = u / (t.length || 1);
|
|
27
|
+
for (; a !== -1;) {
|
|
28
|
+
let i = c + a * f * +(s > 0), o = e.length * f;
|
|
29
|
+
n.push({
|
|
30
|
+
page: r,
|
|
31
|
+
pdfRect: [
|
|
32
|
+
i,
|
|
33
|
+
l,
|
|
34
|
+
i + o,
|
|
35
|
+
l + d
|
|
36
|
+
]
|
|
37
|
+
}), a = t.indexOf(e, a + 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
t || (l(n), d(!1));
|
|
42
|
+
})(), () => {
|
|
43
|
+
t = !0;
|
|
44
|
+
};
|
|
45
|
+
}, p = [a, o], i[1] = a, i[2] = o, i[3] = f, i[4] = p) : (f = i[3], p = i[4]), t(f, p);
|
|
46
|
+
let m;
|
|
47
|
+
return i[5] !== c || i[6] !== u ? (m = {
|
|
48
|
+
matches: c,
|
|
49
|
+
searching: u
|
|
50
|
+
}, i[5] = c, i[6] = u, i[7] = m) : m = i[7], m;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { i as useTextSearch };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import "pdfjs-dist";
|
|
4
|
+
//#region src/hooks/useThumbnails.ts
|
|
5
|
+
var r = e();
|
|
6
|
+
function i(e) {
|
|
7
|
+
let i = (0, r.c)(7), { pdf: a, rotation: o } = e, s;
|
|
8
|
+
i[0] === Symbol.for("react.memo_cache_sentinel") ? (s = [], i[0] = s) : s = i[0];
|
|
9
|
+
let [c, l] = n(s), u, d;
|
|
10
|
+
i[1] !== a || i[2] !== o ? (u = () => {
|
|
11
|
+
a && (async () => {
|
|
12
|
+
let e = [];
|
|
13
|
+
for (let t = 1; t <= a.numPages; t++) {
|
|
14
|
+
let n = await a.getPage(t), r = n.getViewport({
|
|
15
|
+
scale: .2,
|
|
16
|
+
rotation: o
|
|
17
|
+
}), i = document.createElement("canvas"), s = i.getContext("2d");
|
|
18
|
+
s && (i.height = r.height, i.width = r.width, await n.render({
|
|
19
|
+
canvasContext: s,
|
|
20
|
+
viewport: r,
|
|
21
|
+
canvas: i
|
|
22
|
+
}).promise, e.push(i.toDataURL()));
|
|
23
|
+
}
|
|
24
|
+
l(e);
|
|
25
|
+
})();
|
|
26
|
+
}, d = [a, o], i[1] = a, i[2] = o, i[3] = u, i[4] = d) : (u = i[3], d = i[4]), t(u, d);
|
|
27
|
+
let f;
|
|
28
|
+
return i[5] === c ? f = i[6] : (f = { thumbnails: c }, i[5] = c, i[6] = f), f;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { i as useThumbnails };
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import e from "./components/PDFViewer.js";
|
|
2
|
+
import { PDFSidebar as t } from "./components/PDFSidebar.js";
|
|
3
|
+
import { PDFAnnotations as n } from "./components/features/PDFAnnotations.js";
|
|
4
|
+
import { PDFChangeFile as r } from "./components/features/PDFChangeFile.js";
|
|
5
|
+
import { PDFDownloadButton as i } from "./components/features/PDFDownloadButton.js";
|
|
6
|
+
import { PDFNavigation as a } from "./components/features/PDFNavigation.js";
|
|
7
|
+
import { PDFOutline as o } from "./components/features/PDFOutline.js";
|
|
8
|
+
import { PDFPageFit as s } from "./components/features/PDFPageFit.js";
|
|
9
|
+
import { PDFRotationControl as c } from "./components/features/PDFRotationControl.js";
|
|
10
|
+
import { PDFSearch as l } from "./components/features/PDFSearch.js";
|
|
11
|
+
import { PDFSignatures as u } from "./components/features/PDFSignatures.js";
|
|
12
|
+
import { PDFThumbnails as d } from "./components/features/PDFThumbnails.js";
|
|
13
|
+
import { PDFZoomControls as f } from "./components/features/PDFZoomControls.js";
|
|
14
|
+
import { PDFThemeToggle as p } from "./components/features/PDFThemeToggle.js";
|
|
15
|
+
import { PDFPrintButton as m } from "./components/features/PDFPrintButton.js";
|
|
16
|
+
export { n as PDFAnnotations, r as PDFChangeFile, i as PDFDownloadButton, a as PDFNavigation, o as PDFOutline, s as PDFPageFit, m as PDFPrintButton, c as PDFRotationControl, l as PDFSearch, t as PDFSidebar, u as PDFSignatures, p as PDFThemeToggle, d as PDFThumbnails, e as PDFViewer, f as PDFZoomControls };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __commonJSMin as e, __require as t } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region node_modules/react/cjs/react-compiler-runtime.development.js
|
|
3
|
+
var n = /* @__PURE__ */ e(((e) => {
|
|
4
|
+
process.env.NODE_ENV !== "production" && (function() {
|
|
5
|
+
var n = t("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
6
|
+
e.c = function(e) {
|
|
7
|
+
var t = n.H;
|
|
8
|
+
return t === null && console.error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."), t.useMemoCache(e);
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
}));
|
|
12
|
+
//#endregion
|
|
13
|
+
export default n();
|
|
14
|
+
export { n as require_react_compiler_runtime_development };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __commonJSMin as e, __require as t } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region node_modules/react/cjs/react-compiler-runtime.production.js
|
|
3
|
+
var n = /* @__PURE__ */ e(((e) => {
|
|
4
|
+
var n = t("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
5
|
+
e.c = function(e) {
|
|
6
|
+
return n.H.useMemoCache(e);
|
|
7
|
+
};
|
|
8
|
+
}));
|
|
9
|
+
//#endregion
|
|
10
|
+
export default n();
|
|
11
|
+
export { n as require_react_compiler_runtime_production };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __commonJSMin as e } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_react_compiler_runtime_production as t } from "./cjs/react-compiler-runtime.production.js";
|
|
3
|
+
import { require_react_compiler_runtime_development as n } from "./cjs/react-compiler-runtime.development.js";
|
|
4
|
+
//#region node_modules/react/compiler-runtime.js
|
|
5
|
+
var r = /* @__PURE__ */ e(((e, r) => {
|
|
6
|
+
process.env.NODE_ENV === "production" ? r.exports = t() : r.exports = n();
|
|
7
|
+
}));
|
|
8
|
+
//#endregion
|
|
9
|
+
export default r();
|
|
10
|
+
export { r as require_compiler_runtime };
|