pdf-tsx 0.9.0 → 0.10.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.
Files changed (101) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/components/PDFSidebar.cjs +1 -1
  3. package/dist/cjs/components/PDFSidebar.module.cjs +1 -1
  4. package/dist/cjs/components/PDFViewer.cjs +1 -1
  5. package/dist/cjs/components/PDFViewer.module.cjs +1 -1
  6. package/dist/cjs/components/features/PDFAnnotations.cjs +1 -1
  7. package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -1
  8. package/dist/cjs/components/features/PDFAttachments.cjs +1 -1
  9. package/dist/cjs/components/features/PDFAttachments.module.cjs +1 -1
  10. package/dist/cjs/components/features/PDFChangeFile.cjs +1 -1
  11. package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -1
  12. package/dist/cjs/components/features/PDFNavigation.cjs +1 -1
  13. package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -1
  14. package/dist/cjs/components/features/PDFOutline.cjs +1 -1
  15. package/dist/cjs/components/features/PDFOutline.module.cjs +1 -1
  16. package/dist/cjs/components/features/PDFPageFit.cjs +1 -1
  17. package/dist/cjs/components/features/PDFPrintButton.cjs +1 -1
  18. package/dist/cjs/components/features/PDFRotationControl.cjs +1 -1
  19. package/dist/cjs/components/features/PDFSearch.cjs +1 -1
  20. package/dist/cjs/components/features/PDFSearch.module.cjs +1 -1
  21. package/dist/cjs/components/features/PDFSidebarToggle.cjs +1 -1
  22. package/dist/cjs/components/features/PDFSignatures.cjs +1 -1
  23. package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -1
  24. package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -1
  25. package/dist/cjs/components/features/PDFThumbnails.cjs +1 -1
  26. package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -1
  27. package/dist/cjs/components/features/PDFZoomControls.cjs +1 -1
  28. package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -1
  29. package/dist/cjs/components/ui/PDFToolbar.cjs +1 -1
  30. package/dist/cjs/components/ui/PDFToolbar.module.cjs +1 -1
  31. package/dist/cjs/components/ui/PDFToolbarItem.cjs +1 -1
  32. package/dist/cjs/components/ui/ToolbarButton.cjs +1 -1
  33. package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -1
  34. package/dist/cjs/components/ui/icons.cjs +1 -1
  35. package/dist/cjs/context/ThemeContext.cjs +1 -1
  36. package/dist/cjs/hooks/useAnnotationLayer.cjs +1 -1
  37. package/dist/cjs/hooks/useKeyboardShortcuts.cjs +1 -1
  38. package/dist/cjs/hooks/useOutline.cjs +1 -1
  39. package/dist/cjs/hooks/useOverlayRects.cjs +1 -1
  40. package/dist/cjs/hooks/usePDFLoader.cjs +1 -1
  41. package/dist/cjs/hooks/useScrollTracking.cjs +1 -1
  42. package/dist/cjs/hooks/useTextLayer.cjs +1 -1
  43. package/dist/cjs/hooks/useTextSearch.cjs +1 -1
  44. package/dist/cjs/hooks/useThumbnails.cjs +1 -1
  45. package/dist/cjs/pdf-tsx.css +1 -1
  46. package/dist/components/features/PDFSearch.d.ts +1 -1
  47. package/dist/components/features/PDFSidebarToggle.d.ts +1 -1
  48. package/dist/components/features/PDFZoomControls.d.ts +1 -1
  49. package/dist/context/ThemeContext.d.ts +1 -1
  50. package/dist/es/components/PDFSidebar.js +25 -39
  51. package/dist/es/components/PDFSidebar.module.js +9 -9
  52. package/dist/es/components/PDFViewer.js +213 -253
  53. package/dist/es/components/PDFViewer.module.js +15 -15
  54. package/dist/es/components/features/PDFAnnotations.js +54 -62
  55. package/dist/es/components/features/PDFAnnotations.module.js +12 -12
  56. package/dist/es/components/features/PDFAttachments.js +52 -70
  57. package/dist/es/components/features/PDFAttachments.module.js +8 -8
  58. package/dist/es/components/features/PDFChangeFile.js +13 -24
  59. package/dist/es/components/features/PDFDownloadButton.js +10 -13
  60. package/dist/es/components/features/PDFNavigation.js +38 -59
  61. package/dist/es/components/features/PDFNavigation.module.js +3 -3
  62. package/dist/es/components/features/PDFOutline.js +66 -83
  63. package/dist/es/components/features/PDFOutline.module.js +5 -5
  64. package/dist/es/components/features/PDFPageFit.js +18 -23
  65. package/dist/es/components/features/PDFPrintButton.js +14 -17
  66. package/dist/es/components/features/PDFRotationControl.js +7 -13
  67. package/dist/es/components/features/PDFSearch.js +60 -69
  68. package/dist/es/components/features/PDFSearch.module.js +5 -5
  69. package/dist/es/components/features/PDFSidebarToggle.js +8 -13
  70. package/dist/es/components/features/PDFSignatures.js +116 -139
  71. package/dist/es/components/features/PDFSignatures.module.js +16 -16
  72. package/dist/es/components/features/PDFThemeToggle.js +10 -11
  73. package/dist/es/components/features/PDFThumbnails.js +25 -34
  74. package/dist/es/components/features/PDFThumbnails.module.js +9 -9
  75. package/dist/es/components/features/PDFZoomControls.js +21 -36
  76. package/dist/es/components/features/PDFZoomControls.module.js +1 -1
  77. package/dist/es/components/ui/PDFToolbar.js +53 -83
  78. package/dist/es/components/ui/PDFToolbar.module.js +9 -9
  79. package/dist/es/components/ui/PDFToolbarItem.js +10 -19
  80. package/dist/es/components/ui/ToolbarButton.js +8 -11
  81. package/dist/es/components/ui/ToolbarButton.module.js +2 -2
  82. package/dist/es/components/ui/icons.js +5 -16
  83. package/dist/es/context/ThemeContext.js +28 -38
  84. package/dist/es/hooks/useAnnotationLayer.js +33 -42
  85. package/dist/es/hooks/useKeyboardShortcuts.js +25 -34
  86. package/dist/es/hooks/useOutline.js +18 -23
  87. package/dist/es/hooks/useOverlayRects.js +42 -51
  88. package/dist/es/hooks/usePDFLoader.js +13 -16
  89. package/dist/es/hooks/useScrollTracking.js +24 -25
  90. package/dist/es/hooks/useTextLayer.js +34 -43
  91. package/dist/es/hooks/useTextSearch.js +31 -38
  92. package/dist/es/hooks/useThumbnails.js +33 -44
  93. package/dist/es/pdf-tsx.css +1 -1
  94. package/dist/hooks/useAttachments.d.ts +1 -1
  95. package/dist/hooks/useOutline.d.ts +1 -1
  96. package/dist/hooks/useOverlayRects.d.ts +1 -1
  97. package/dist/hooks/usePDFRenderer.d.ts +1 -1
  98. package/dist/hooks/useSignatures.d.ts +1 -1
  99. package/dist/hooks/useThumbnails.d.ts +1 -1
  100. package/dist/index.d.ts +3 -3
  101. package/package.json +3 -3
@@ -1,115 +1,85 @@
1
1
  import { ToolbarButton as e } from "./ToolbarButton.js";
2
2
  import t from "./PDFToolbar.module.js";
3
3
  import { PDFToolbarDropdownContext as n } from "./PDFToolbarDropdownContext.js";
4
- import { c as r } from "react/compiler-runtime";
5
- import i, { useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
4
+ import r, { useCallback as i, useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
6
5
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
6
  //#region src/components/ui/PDFToolbar.tsx
8
7
  var d = 40;
9
- function f(n) {
10
- let f = r(30), { children: _, overflowIcon: v } = n, y = v === void 0 ? "···" : v, b = s(null), x;
11
- f[0] === Symbol.for("react.memo_cache_sentinel") ? (x = [], f[0] = x) : x = f[0];
12
- let S = s(x), C;
13
- f[1] === Symbol.for("react.memo_cache_sentinel") ? (C = [], f[1] = C) : C = f[1];
14
- let w = s(C), [T, E] = c(null), [D, O] = c(!1), k = s(null), A;
15
- f[2] === _ ? A = f[3] : (A = i.Children.toArray(_), f[2] = _, f[3] = A);
16
- let j = A, M;
17
- f[4] === Symbol.for("react.memo_cache_sentinel") ? (M = () => {
18
- let e = b.current, t = w.current;
8
+ function f({ children: f, overflowIcon: p = "···" }) {
9
+ let m = s(null), h = s([]), g = s([]), [_, v] = c(null), [y, b] = c(!1), x = s(null), S = r.Children.toArray(f), C = i(() => {
10
+ let e = m.current, t = g.current;
19
11
  if (!e || t.length === 0) return;
20
12
  let n = e.offsetWidth;
21
- if (t.reduce(g, 0) <= n) {
22
- E(null);
13
+ if (t.reduce((e, t) => e + t, 0) <= n) {
14
+ v(null);
23
15
  return;
24
16
  }
25
17
  let r = 0, i = 0;
26
18
  for (let e = 0; e < t.length && r + t[e] + d <= n; e++) r += t[e], i++;
27
- E(i);
28
- }, f[4] = M) : M = f[4];
29
- let N = M, P;
30
- f[5] === j.length ? P = f[6] : (P = () => {
31
- w.current = S.current.slice(0, j.length).map(h), N();
32
- }, f[5] = j.length, f[6] = P);
33
- let F;
34
- f[7] === Symbol.for("react.memo_cache_sentinel") ? (F = [], f[7] = F) : F = f[7], o(P, F);
35
- let I, L;
36
- f[8] === Symbol.for("react.memo_cache_sentinel") ? (I = () => {
37
- let e = b.current;
19
+ v(i);
20
+ }, []);
21
+ o(() => {
22
+ g.current = h.current.slice(0, S.length).map((e) => e?.offsetWidth ?? 0), C();
23
+ }, []), a(() => {
24
+ let e = m.current;
38
25
  if (!e) return;
39
- let t = new ResizeObserver(() => N());
26
+ let t = new ResizeObserver(() => C());
40
27
  return t.observe(e), () => t.disconnect();
41
- }, L = [N], f[8] = I, f[9] = L) : (I = f[8], L = f[9]), a(I, L);
42
- let R, z;
43
- f[10] === D ? (R = f[11], z = f[12]) : (R = () => {
44
- if (!D) return;
28
+ }, [C]), a(() => {
29
+ if (!y) return;
45
30
  let e = (e) => {
46
- k.current?.contains(e.target) || O(!1);
31
+ x.current?.contains(e.target) || b(!1);
47
32
  };
48
33
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
49
- }, z = [D], f[10] = D, f[11] = R, f[12] = z), a(R, z);
50
- let B = T !== null && T < j.length, V, H, U, W;
51
- if (f[13] !== B || f[14] !== j || f[15] !== y || f[16] !== D || f[17] !== T) {
52
- let n = B ? j.slice(T) : [];
53
- V = b, H = t.toolbar, f[22] !== j || f[23] !== T ? (U = j.map((e, n) => /* @__PURE__ */ l("div", {
34
+ }, [y]);
35
+ let w = _ !== null && _ < S.length, T = w ? S.slice(_) : [];
36
+ return /* @__PURE__ */ u("div", {
37
+ ref: m,
38
+ className: t.toolbar,
39
+ children: [S.map((e, n) => /* @__PURE__ */ l("div", {
54
40
  ref: (e) => {
55
- S.current[n] = e;
41
+ h.current[n] = e;
56
42
  },
57
43
  className: t.item,
58
- style: T !== null && n >= T ? { display: "none" } : void 0,
44
+ style: _ !== null && n >= _ ? { display: "none" } : void 0,
59
45
  children: e
60
- }, n)), f[22] = j, f[23] = T, f[24] = U) : U = f[24], W = B && /* @__PURE__ */ u("div", {
61
- ref: k,
46
+ }, n)), w && /* @__PURE__ */ u("div", {
47
+ ref: x,
62
48
  className: t.overflowWrapper,
63
49
  children: [/* @__PURE__ */ l(e, {
64
- onClick: () => O(m),
50
+ onClick: () => b((e) => !e),
65
51
  "aria-label": "Altre opzioni",
66
- "aria-expanded": D,
52
+ "aria-expanded": y,
67
53
  "aria-haspopup": "true",
68
54
  title: "Altre opzioni",
69
- className: D ? t.overflowBtnActive : void 0,
70
- children: y
71
- }), D && /* @__PURE__ */ l("div", {
55
+ className: y ? t.overflowBtnActive : void 0,
56
+ children: p
57
+ }), y && /* @__PURE__ */ l("div", {
72
58
  className: t.dropdown,
73
59
  role: "menu",
74
- children: n.map(p)
60
+ children: T.map((e, i) => {
61
+ let a = r.isValidElement(e) ? e.type.toolbarLabel : void 0;
62
+ return /* @__PURE__ */ l("div", {
63
+ className: t.dropdownItem,
64
+ role: "menuitem",
65
+ children: a ? /* @__PURE__ */ u("div", {
66
+ className: t.labeledItem,
67
+ children: [/* @__PURE__ */ l("span", {
68
+ className: t.itemLabel,
69
+ children: a
70
+ }), /* @__PURE__ */ l("div", {
71
+ className: t.itemContent,
72
+ children: e
73
+ })]
74
+ }) : /* @__PURE__ */ l(n.Provider, {
75
+ value: !0,
76
+ children: e
77
+ })
78
+ }, i);
79
+ })
75
80
  })]
76
- }), f[13] = B, f[14] = j, f[15] = y, f[16] = D, f[17] = T, f[18] = V, f[19] = H, f[20] = U, f[21] = W;
77
- } else V = f[18], H = f[19], U = f[20], W = f[21];
78
- let G;
79
- return f[25] !== V || f[26] !== H || f[27] !== U || f[28] !== W ? (G = /* @__PURE__ */ u("div", {
80
- ref: V,
81
- className: H,
82
- children: [U, W]
83
- }), f[25] = V, f[26] = H, f[27] = U, f[28] = W, f[29] = G) : G = f[29], G;
84
- }
85
- function p(e, r) {
86
- let a = i.isValidElement(e) ? e.type.toolbarLabel : void 0;
87
- return /* @__PURE__ */ l("div", {
88
- className: t.dropdownItem,
89
- role: "menuitem",
90
- children: a ? /* @__PURE__ */ u("div", {
91
- className: t.labeledItem,
92
- children: [/* @__PURE__ */ l("span", {
93
- className: t.itemLabel,
94
- children: a
95
- }), /* @__PURE__ */ l("div", {
96
- className: t.itemContent,
97
- children: e
98
- })]
99
- }) : /* @__PURE__ */ l(n.Provider, {
100
- value: !0,
101
- children: e
102
- })
103
- }, r);
104
- }
105
- function m(e) {
106
- return !e;
107
- }
108
- function h(e) {
109
- return e?.offsetWidth ?? 0;
110
- }
111
- function g(e, t) {
112
- return e + t;
81
+ })]
82
+ });
113
83
  }
114
84
  //#endregion
115
85
  export { f as PDFToolbar };
@@ -1,13 +1,13 @@
1
1
  var e = {
2
- toolbar: "_toolbar_1k80o_1",
3
- item: "_item_1k80o_17",
4
- overflowWrapper: "_overflowWrapper_1k80o_29",
5
- overflowBtnActive: "_overflowBtnActive_1k80o_41",
6
- dropdown: "_dropdown_1k80o_51",
7
- dropdownItem: "_dropdownItem_1k80o_81",
8
- labeledItem: "_labeledItem_1k80o_105",
9
- itemContent: "_itemContent_1k80o_119",
10
- itemLabel: "_itemLabel_1k80o_131"
2
+ toolbar: "_toolbar_xoqxq_1",
3
+ item: "_item_xoqxq_9",
4
+ overflowWrapper: "_overflowWrapper_xoqxq_15",
5
+ overflowBtnActive: "_overflowBtnActive_xoqxq_21",
6
+ dropdown: "_dropdown_xoqxq_26",
7
+ dropdownItem: "_dropdownItem_xoqxq_41",
8
+ labeledItem: "_labeledItem_xoqxq_53",
9
+ itemContent: "_itemContent_xoqxq_60",
10
+ itemLabel: "_itemLabel_xoqxq_66"
11
11
  };
12
12
  //#endregion
13
13
  export { e as default };
@@ -1,25 +1,16 @@
1
1
  import e from "./PDFToolbar.module.js";
2
2
  import { PDFToolbarDropdownContext as t } from "./PDFToolbarDropdownContext.js";
3
- import { c as n } from "react/compiler-runtime";
4
- import { useContext as r } from "react";
5
- import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
3
+ import { useContext as n } from "react";
4
+ import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
6
5
  //#region src/components/ui/PDFToolbarItem.tsx
7
- function s(s) {
8
- let c = n(7), { children: l, label: u } = s;
9
- if (!r(t) || !u) {
10
- let e;
11
- return c[0] === l ? e = c[1] : (e = /* @__PURE__ */ a(i, { children: l }), c[0] = l, c[1] = e), e;
12
- }
13
- let d;
14
- c[2] === u ? d = c[3] : (d = /* @__PURE__ */ a("span", {
15
- className: e.itemLabel,
16
- children: u
17
- }), c[2] = u, c[3] = d);
18
- let f;
19
- return c[4] !== l || c[5] !== d ? (f = /* @__PURE__ */ o("div", {
6
+ function o({ children: o, label: s }) {
7
+ return !n(t) || !s ? /* @__PURE__ */ i(r, { children: o }) : /* @__PURE__ */ a("div", {
20
8
  className: e.labeledItem,
21
- children: [d, l]
22
- }), c[4] = l, c[5] = d, c[6] = f) : f = c[6], f;
9
+ children: [/* @__PURE__ */ i("span", {
10
+ className: e.itemLabel,
11
+ children: s
12
+ }), o]
13
+ });
23
14
  }
24
15
  //#endregion
25
- export { s as PDFToolbarItem };
16
+ export { o as PDFToolbarItem };
@@ -1,15 +1,12 @@
1
1
  import e from "./ToolbarButton.module.js";
2
- import { c as t } from "react/compiler-runtime";
3
- import { jsx as n } from "react/jsx-runtime";
2
+ import { jsx as t } from "react/jsx-runtime";
4
3
  //#region src/components/ui/ToolbarButton.tsx
5
- function r(r) {
6
- let i = t(7), a, o, s;
7
- i[0] === r ? (a = i[1], o = i[2], s = i[3]) : ({$primary: a, className: o, ...s} = r, i[0] = r, i[1] = a, i[2] = o, i[3] = s);
8
- let c = a ? `${e.btn} ${e.primary}` : e.btn, l = o ? `${c} ${o}` : c, u;
9
- return i[4] !== s || i[5] !== l ? (u = /* @__PURE__ */ n("button", {
10
- className: l,
11
- ...s
12
- }), i[4] = s, i[5] = l, i[6] = u) : u = i[6], u;
4
+ function n({ $primary: n, className: r, ...i }) {
5
+ let a = n ? `${e.btn} ${e.primary}` : e.btn;
6
+ return /* @__PURE__ */ t("button", {
7
+ className: r ? `${a} ${r}` : a,
8
+ ...i
9
+ });
13
10
  }
14
11
  //#endregion
15
- export { r as ToolbarButton };
12
+ export { n as ToolbarButton };
@@ -1,6 +1,6 @@
1
1
  var e = {
2
- btn: "_btn_12ml0_1",
3
- primary: "_primary_12ml0_57"
2
+ btn: "_btn_1dub8_1",
3
+ primary: "_primary_1dub8_31"
4
4
  };
5
5
  //#endregion
6
6
  export { e as default };
@@ -1,8 +1,7 @@
1
- import { c as e } from "react/compiler-runtime";
2
1
  import "react";
3
- import { jsx as t } from "react/jsx-runtime";
2
+ import { jsx as e } from "react/jsx-runtime";
4
3
  //#region src/components/ui/icons.tsx
5
- var n = (e, n = 16) => /* @__PURE__ */ t("svg", {
4
+ var t = (t, n = 16) => /* @__PURE__ */ e("svg", {
6
5
  xmlns: "http://www.w3.org/2000/svg",
7
6
  width: n,
8
7
  height: n,
@@ -12,17 +11,7 @@ var n = (e, n = 16) => /* @__PURE__ */ t("svg", {
12
11
  strokeWidth: 2,
13
12
  strokeLinecap: "round",
14
13
  strokeLinejoin: "round",
15
- children: e
16
- }), r = (r) => {
17
- let i = e(3), { size: a } = r, 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 = n(o, a), i[1] = a, i[2] = s), s;
21
- }, i = (r) => {
22
- let i = e(3), { size: a } = r, 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 = n(o, a), i[1] = a, i[2] = s), s;
26
- };
14
+ children: t
15
+ }), n = ({ size: n }) => t(/* @__PURE__ */ e("polyline", { points: "9 18 15 12 9 6" }), n), r = ({ size: n }) => t(/* @__PURE__ */ e("polyline", { points: "6 9 12 15 18 9" }), n);
27
16
  //#endregion
28
- export { i as IconChevronDown, r as IconChevronRight };
17
+ export { r as IconChevronDown, n as IconChevronRight };
@@ -1,46 +1,36 @@
1
1
  import { darkTheme as e, lightTheme as t, themeToCssVars as n } from "../theme.js";
2
2
  import { ThemeContext as r } from "./themeContextValue.js";
3
- import { c as i } from "react/compiler-runtime";
4
- import { useState as a } from "react";
5
- import { jsx as o } from "react/jsx-runtime";
3
+ import { useCallback as i, useMemo as a, useState as o } from "react";
4
+ import { jsx as s } from "react/jsx-runtime";
6
5
  //#region src/context/ThemeContext.tsx
7
- function s(s) {
8
- let l = i(17), { children: u, themeOverrides: d, defaultTheme: f } = s, [p, m] = a((f === void 0 ? "light" : f) === "dark"), h, g;
9
- l[0] !== p || l[1] !== d?.dark || l[2] !== d?.light ? (g = p ? {
6
+ function c({ children: c, themeOverrides: l, defaultTheme: u = "light" }) {
7
+ let [d, f] = o(u === "dark"), p = a(() => d ? {
10
8
  ...e,
11
- ...d?.dark
9
+ ...l?.dark
12
10
  } : {
13
11
  ...t,
14
- ...d?.light
15
- }, h = n(g), l[0] = p, l[1] = d?.dark, l[2] = d?.light, l[3] = h, l[4] = g) : (h = l[3], g = l[4]);
16
- let _ = h, v;
17
- l[5] === Symbol.for("react.memo_cache_sentinel") ? (v = () => m(c), l[5] = v) : v = l[5];
18
- let y;
19
- l[6] !== p || l[7] !== g ? (y = {
20
- isDark: p,
21
- toggleTheme: v,
22
- theme: g
23
- }, l[6] = p, l[7] = g, l[8] = y) : y = l[8];
24
- let b = _, x;
25
- l[9] === b ? x = l[10] : (x = {
26
- ...b,
27
- fontFamily: "var(--pdf-font-family)",
28
- height: "100%",
29
- width: "100%"
30
- }, l[9] = b, l[10] = x);
31
- let S;
32
- l[11] !== u || l[12] !== x ? (S = /* @__PURE__ */ o("div", {
33
- style: x,
34
- children: u
35
- }), l[11] = u, l[12] = x, l[13] = S) : S = l[13];
36
- let C;
37
- return l[14] !== y || l[15] !== S ? (C = /* @__PURE__ */ o(r.Provider, {
38
- value: y,
39
- children: S
40
- }), l[14] = y, l[15] = S, l[16] = C) : C = l[16], C;
41
- }
42
- function c(e) {
43
- return !e;
12
+ ...l?.light
13
+ }, [d, l]), m = a(() => n(p), [p]), h = i(() => f((e) => !e), []), g = a(() => ({
14
+ isDark: d,
15
+ toggleTheme: h,
16
+ theme: p
17
+ }), [
18
+ d,
19
+ h,
20
+ p
21
+ ]);
22
+ return /* @__PURE__ */ s(r.Provider, {
23
+ value: g,
24
+ children: /* @__PURE__ */ s("div", {
25
+ style: {
26
+ ...m,
27
+ fontFamily: "var(--pdf-font-family)",
28
+ height: "100%",
29
+ width: "100%"
30
+ },
31
+ children: c
32
+ })
33
+ });
44
34
  }
45
35
  //#endregion
46
- export { s as ThemeProvider };
36
+ export { c as ThemeProvider };
@@ -1,70 +1,61 @@
1
1
  import { isSafeUrl as e } from "../utils/url.js";
2
- import { c as t } from "react/compiler-runtime";
3
- import { useEffect as n, useState as r } from "react";
2
+ import { useEffect as t, useState as n } from "react";
4
3
  import "pdfjs-dist";
5
4
  //#region src/hooks/useAnnotationLayer.ts
6
- function i(i) {
7
- let a = t(15), { pdf: o, zoom: s, rotation: c, mountedPages: l, goToPage: u } = i, d;
8
- a[0] === Symbol.for("react.memo_cache_sentinel") ? (d = [], a[0] = d) : d = a[0];
9
- let [f, p] = r(d), m, h;
10
- a[1] !== l || a[2] !== o || a[3] !== c || a[4] !== s ? (m = () => {
11
- if (!o) return;
5
+ function r({ pdf: r, zoom: i, rotation: a, mountedPages: o, goToPage: s }) {
6
+ let [c, l] = n([]);
7
+ t(() => {
8
+ if (!r) return;
12
9
  let e = !1;
13
10
  return (async () => {
14
11
  let t = [];
15
- for (let n of l) {
12
+ for (let n of o) {
16
13
  if (e) break;
17
- let r = await o.getPage(n), i = r.getViewport({
18
- scale: s,
19
- rotation: c
20
- }), a = await r.getAnnotations();
21
- for (let e of a) {
14
+ let o = await r.getPage(n), s = o.getViewport({
15
+ scale: i,
16
+ rotation: a
17
+ }), c = await o.getAnnotations();
18
+ for (let e of c) {
22
19
  if (e.subtype !== "Link" || !e.rect) continue;
23
- let r = e.rect, [a, o, s, c] = i.convertToViewportRectangle(r);
20
+ let r = e.rect, [i, a, o, c] = s.convertToViewportRectangle(r);
24
21
  t.push({
25
22
  page: n,
26
- x: Math.min(a, s),
27
- y: Math.min(o, c),
28
- width: Math.abs(s - a),
29
- height: Math.abs(c - o),
23
+ x: Math.min(i, o),
24
+ y: Math.min(a, c),
25
+ width: Math.abs(o - i),
26
+ height: Math.abs(c - a),
30
27
  url: e.url,
31
28
  dest: e.dest,
32
29
  newWindow: e.newWindow
33
30
  });
34
31
  }
35
32
  }
36
- e || p(t);
33
+ e || l(t);
37
34
  })(), () => {
38
35
  e = !0;
39
36
  };
40
- }, h = [
41
- o,
42
- s,
43
- c,
44
- l
45
- ], 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);
46
- let g;
47
- a[7] !== u || a[8] !== o ? (g = async (t) => {
37
+ }, [
38
+ r,
39
+ i,
40
+ a,
41
+ o
42
+ ]);
43
+ let u = async (t) => {
48
44
  if (t.url) {
49
45
  if (!e(t.url)) return;
50
46
  window.open(t.url, "_blank", "noopener,noreferrer");
51
47
  return;
52
48
  }
53
- if (t.dest && o) {
49
+ if (t.dest && r) {
54
50
  let e = null;
55
- if (typeof t.dest == "string" ? e = await o.getDestination(t.dest) : Array.isArray(t.dest) && (e = t.dest), !e) return;
56
- u(await o.getPageIndex(e[0]) + 1);
51
+ if (typeof t.dest == "string" ? e = await r.getDestination(t.dest) : Array.isArray(t.dest) && (e = t.dest), !e) return;
52
+ s(await r.getPageIndex(e[0]) + 1);
57
53
  }
58
- }, a[7] = u, a[8] = o, a[9] = g) : g = a[9];
59
- let _ = g, v;
60
- if (a[10] !== _ || a[11] !== f) {
61
- let e;
62
- a[13] === _ ? e = a[14] : (e = (e) => ({
63
- ...e,
64
- _handleClick: _.bind(null, e)
65
- }), a[13] = _, a[14] = e), v = f.map(e), a[10] = _, a[11] = f, a[12] = v;
66
- } else v = a[12];
67
- return v;
54
+ };
55
+ return c.map((e) => ({
56
+ ...e,
57
+ _handleClick: u.bind(null, e)
58
+ }));
68
59
  }
69
60
  //#endregion
70
- export { i as useAnnotationLayer };
61
+ export { r as useAnnotationLayer };
@@ -1,51 +1,42 @@
1
- import { c as e } from "react/compiler-runtime";
2
- import { useEffect as t } from "react";
1
+ import { useEffect as e } from "react";
3
2
  import "pdfjs-dist";
4
3
  //#region src/hooks/useKeyboardShortcuts.ts
5
- function n(n) {
6
- let o = e(8), { pdf: s, currentPage: c, goToPage: l, setZoom: u, setRotation: d, setFitMode: f } = n, p, m;
7
- o[0] !== c || o[1] !== l || o[2] !== s || o[3] !== f || o[4] !== d || o[5] !== u ? (p = () => {
8
- if (!s) return;
4
+ function t({ pdf: t, currentPage: n, goToPage: r, setZoom: i, setRotation: a, setFitMode: o }) {
5
+ e(() => {
6
+ if (!t) return;
9
7
  let e = (e) => {
10
8
  let t = e.target.tagName;
11
- if (!(t === "INPUT" || t === "TEXTAREA")) bb13: switch (e.key) {
9
+ if (!(t === "INPUT" || t === "TEXTAREA")) switch (e.key) {
12
10
  case "ArrowLeft":
13
11
  case "ArrowUp":
14
- e.preventDefault(), l(c - 1);
15
- break bb13;
12
+ e.preventDefault(), r(n - 1);
13
+ break;
16
14
  case "ArrowRight":
17
15
  case "ArrowDown":
18
- e.preventDefault(), l(c + 1);
19
- break bb13;
16
+ e.preventDefault(), r(n + 1);
17
+ break;
20
18
  case "+":
21
19
  case "=":
22
- e.preventDefault(), f(null), u(a);
23
- break bb13;
20
+ e.preventDefault(), o(null), i((e) => Math.min(e + .2, 3));
21
+ break;
24
22
  case "-":
25
- e.preventDefault(), f(null), u(i);
26
- break bb13;
23
+ e.preventDefault(), o(null), i((e) => Math.max(e - .2, .2));
24
+ break;
27
25
  case "r":
28
- case "R": e.preventDefault(), d(r);
26
+ case "R":
27
+ e.preventDefault(), a((e) => (e + 90) % 360);
28
+ break;
29
29
  }
30
30
  };
31
31
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
32
- }, m = [
33
- s,
34
- c,
35
- l,
36
- u,
37
- d,
38
- f
39
- ], o[0] = c, o[1] = l, o[2] = s, o[3] = f, o[4] = d, o[5] = u, o[6] = p, o[7] = m) : (p = o[6], m = o[7]), t(p, m);
40
- }
41
- function r(e) {
42
- return (e + 90) % 360;
43
- }
44
- function i(e) {
45
- return Math.max(e - .2, .2);
46
- }
47
- function a(e) {
48
- return Math.min(e + .2, 3);
32
+ }, [
33
+ t,
34
+ n,
35
+ r,
36
+ i,
37
+ a,
38
+ o
39
+ ]);
49
40
  }
50
41
  //#endregion
51
- export { n as useKeyboardShortcuts };
42
+ export { t as useKeyboardShortcuts };
@@ -1,38 +1,33 @@
1
- import { c as e } from "react/compiler-runtime";
2
- import { useEffect as t, useState as n } from "react";
1
+ import { useEffect as e, useState as t } from "react";
3
2
  import "pdfjs-dist";
4
3
  //#region src/hooks/useOutline.ts
5
- function r(r) {
6
- let i = e(10), { pdf: a } = r, o;
7
- i[0] === Symbol.for("react.memo_cache_sentinel") ? (o = {
4
+ function n({ pdf: n }) {
5
+ let [r, i] = t({
8
6
  pdf: null,
9
7
  outline: []
10
- }, i[0] = o) : o = i[0];
11
- let [s, c] = n(o), l, u;
12
- i[1] === a ? (l = i[2], u = i[3]) : (l = () => {
13
- if (!a) return;
8
+ });
9
+ e(() => {
10
+ if (!n) return;
14
11
  let e = !1;
15
- return a.getOutline().then((t) => {
16
- e || c({
17
- pdf: a,
12
+ return n.getOutline().then((t) => {
13
+ e || i({
14
+ pdf: n,
18
15
  outline: t ?? []
19
16
  });
20
17
  }).catch(() => {
21
- e || c({
22
- pdf: a,
18
+ e || i({
19
+ pdf: n,
23
20
  outline: []
24
21
  });
25
22
  }), () => {
26
23
  e = !0;
27
24
  };
28
- }, u = [a], i[1] = a, i[2] = l, i[3] = u), t(l, u);
29
- let d = a !== null && s.pdf !== a, f;
30
- i[4] !== d || i[5] !== s ? (f = d ? [] : s.outline, i[4] = d, i[5] = s, i[6] = f) : f = i[6];
31
- let p;
32
- return i[7] !== d || i[8] !== f ? (p = {
33
- outline: f,
34
- loading: d
35
- }, i[7] = d, i[8] = f, i[9] = p) : p = i[9], p;
25
+ }, [n]);
26
+ let a = n !== null && r.pdf !== n;
27
+ return {
28
+ outline: a ? [] : r.outline,
29
+ loading: a
30
+ };
36
31
  }
37
32
  //#endregion
38
- export { r as useOutline };
33
+ export { n as useOutline };