@prose-reader/react-reader 1.189.0 → 1.191.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/dist/index.js +35 -30
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +2 -4
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c, Fragment as U } from "react/jsx-runtime";
|
|
2
2
|
import * as D from "react";
|
|
3
|
-
import fe, { createContext as me, memo as f, useMemo as be, useEffect as Q, useContext as le, useState as
|
|
3
|
+
import fe, { createContext as me, memo as f, useMemo as be, useEffect as Q, useContext as le, useState as y, useCallback as M } from "react";
|
|
4
4
|
import { signal as xe, useSignal as se, useLiveRef as Ce, useSubscribe as ae, useObserve as b, useSignalValue as ve } from "reactjrx";
|
|
5
5
|
import { tap as ke, switchMap as ce, NEVER as Ie, combineLatest as Se, map as de, startWith as Pe } from "rxjs";
|
|
6
|
-
import { IconButton as m, Portal as he, Dialog as k, List as S, Link as G, Stack as P, Text as p, Button as E, Presence as q, Box as A, Heading as W, HStack as O, Kbd as re, Popover as z, Progress as _, chakra as
|
|
7
|
-
import { LuX as
|
|
6
|
+
import { IconButton as m, Portal as he, Dialog as k, List as S, Link as G, Stack as P, Text as p, Button as E, Presence as q, Box as A, Heading as W, HStack as O, Kbd as re, Popover as z, Progress as _, chakra as we, Collapsible as K, Input as ye } from "@chakra-ui/react";
|
|
7
|
+
import { LuX as Te, LuNotebookPen as X, LuArrowBigRight as Re, LuArrowBigLeft as Oe, LuChevronDown as De, LuCircleHelp as ze, LuTableOfContents as Ae, LuSearch as Ee, LuCircleCheck as ie } from "react-icons/lu";
|
|
8
8
|
import { createPortal as Be } from "react-dom";
|
|
9
9
|
import { BsBookmarkPlus as Me, BsBookmarkXFill as _e, BsBookmarks as Le } from "react-icons/bs";
|
|
10
10
|
import { RxDoubleArrowUp as $e, RxDoubleArrowLeft as Ne, RxDoubleArrowDown as Fe, RxDoubleArrowRight as He } from "react-icons/rx";
|
|
@@ -40,7 +40,7 @@ const J = me({
|
|
|
40
40
|
), /* @__PURE__ */ e(J.Provider, { value: a, children: n });
|
|
41
41
|
}
|
|
42
42
|
), Ge = D.forwardRef(function(t, o) {
|
|
43
|
-
return /* @__PURE__ */ e(m, { variant: "ghost", "aria-label": "Close", ref: o, ...t, children: t.children ?? /* @__PURE__ */ e(
|
|
43
|
+
return /* @__PURE__ */ e(m, { variant: "ghost", "aria-label": "Close", ref: o, ...t, children: t.children ?? /* @__PURE__ */ e(Te, {}) });
|
|
44
44
|
}), L = D.forwardRef(function(t, o) {
|
|
45
45
|
const {
|
|
46
46
|
children: r,
|
|
@@ -70,12 +70,12 @@ k.Backdrop;
|
|
|
70
70
|
const V = k.Title;
|
|
71
71
|
k.Description;
|
|
72
72
|
k.Trigger;
|
|
73
|
-
const Y = k.ActionTrigger,
|
|
73
|
+
const Y = k.ActionTrigger, T = () => {
|
|
74
74
|
const { reader: n } = le(J);
|
|
75
75
|
return n;
|
|
76
76
|
}, ue = (n) => !!n && "__PROSE_READER_ENHANCER_SEARCH" in n, Z = (n) => !!n && "__PROSE_READER_ENHANCER_BOOKMARKS" in n, ge = (n) => !!n && "__PROSE_READER_ENHANCER_ANNOTATIONS" in n, Ke = f(
|
|
77
77
|
({ onNavigate: n }) => {
|
|
78
|
-
const t =
|
|
78
|
+
const t = T(), o = ge(t) ? t : void 0, r = b(
|
|
79
79
|
() => o == null ? void 0 : o.annotations.highlights$.pipe(
|
|
80
80
|
ce(
|
|
81
81
|
(i) => o.pagination.locate(i)
|
|
@@ -136,7 +136,7 @@ const Y = k.ActionTrigger, y = () => {
|
|
|
136
136
|
}
|
|
137
137
|
)
|
|
138
138
|
), Xe = f(() => {
|
|
139
|
-
const n =
|
|
139
|
+
const n = T(), t = Z(n) ? n : void 0, o = b(() => n == null ? void 0 : n.spine.element$, [n]), r = b(
|
|
140
140
|
() => t == null ? void 0 : t.bookmarks.pages$,
|
|
141
141
|
[t]
|
|
142
142
|
), l = b(
|
|
@@ -175,6 +175,8 @@ const Y = k.ActionTrigger, y = () => {
|
|
|
175
175
|
m,
|
|
176
176
|
{
|
|
177
177
|
"aria-label": "bookmark",
|
|
178
|
+
opacity: 0.5,
|
|
179
|
+
_hover: { opacity: 1 },
|
|
178
180
|
onClick: () => {
|
|
179
181
|
d && (t == null || t.bookmarks.delete(
|
|
180
182
|
d == null ? void 0 : d.id
|
|
@@ -193,6 +195,9 @@ const Y = k.ActionTrigger, y = () => {
|
|
|
193
195
|
t == null || t.bookmarks.bookmark(g);
|
|
194
196
|
},
|
|
195
197
|
size: "lg",
|
|
198
|
+
bgColor: "white",
|
|
199
|
+
opacity: 0.5,
|
|
200
|
+
_hover: { opacity: 1 },
|
|
196
201
|
variant: "ghost",
|
|
197
202
|
_icon: { boxSize: "36px" },
|
|
198
203
|
children: /* @__PURE__ */ e(Me, {})
|
|
@@ -209,7 +214,7 @@ const Y = k.ActionTrigger, y = () => {
|
|
|
209
214
|
) }) : null;
|
|
210
215
|
}), Je = f(
|
|
211
216
|
({ onNavigate: n }) => {
|
|
212
|
-
const t =
|
|
217
|
+
const t = T(), o = Z(t) ? t : void 0, r = b(
|
|
213
218
|
() => o == null ? void 0 : o.bookmarks.bookmarks$.pipe(
|
|
214
219
|
ce((i) => o.pagination.locate(i))
|
|
215
220
|
),
|
|
@@ -280,7 +285,7 @@ const Y = k.ActionTrigger, y = () => {
|
|
|
280
285
|
] })
|
|
281
286
|
}
|
|
282
287
|
)
|
|
283
|
-
), en = "@prose-reader/react-reader", nn = "1.
|
|
288
|
+
), en = "@prose-reader/react-reader", nn = "1.190.0", tn = f(
|
|
284
289
|
({
|
|
285
290
|
open: n,
|
|
286
291
|
setOpen: t
|
|
@@ -320,7 +325,7 @@ const Y = k.ActionTrigger, y = () => {
|
|
|
320
325
|
}
|
|
321
326
|
)
|
|
322
327
|
), B = () => {
|
|
323
|
-
const n =
|
|
328
|
+
const n = T();
|
|
324
329
|
return b(
|
|
325
330
|
() => n ? Se([n.pagination.state$, n.context.state$]).pipe(
|
|
326
331
|
de(([t, o]) => {
|
|
@@ -348,7 +353,7 @@ const Y = k.ActionTrigger, y = () => {
|
|
|
348
353
|
" %"
|
|
349
354
|
] }) });
|
|
350
355
|
}, rn = () => {
|
|
351
|
-
const [n, t] =
|
|
356
|
+
const [n, t] = y(/* @__PURE__ */ new Date());
|
|
352
357
|
return Q(() => {
|
|
353
358
|
const o = setInterval(() => {
|
|
354
359
|
t(/* @__PURE__ */ new Date());
|
|
@@ -507,7 +512,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
507
512
|
children: n
|
|
508
513
|
}
|
|
509
514
|
)
|
|
510
|
-
), pn =
|
|
515
|
+
), pn = we(Ve), fn = f((n) => /* @__PURE__ */ e(
|
|
511
516
|
A,
|
|
512
517
|
{
|
|
513
518
|
display: "contents",
|
|
@@ -577,7 +582,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
577
582
|
max: u
|
|
578
583
|
};
|
|
579
584
|
}, bn = (n) => {
|
|
580
|
-
const t =
|
|
585
|
+
const t = T(), o = B(), { manifest: r } = b(() => t == null ? void 0 : t.context.state$, []) ?? {}, l = (r == null ? void 0 : r.readingDirection) === "rtl", i = o == null ? void 0 : o.isUsingSpread, { totalApproximatePages: a = 0, isBeginWithinChapter: h } = ne(), u = 1, s = h, { value: g, valueSignal: d, min: x, max: C } = mn(), w = M(
|
|
581
586
|
(v) => {
|
|
582
587
|
const [R = 0] = Array.isArray(v) ? v : [v];
|
|
583
588
|
d.setValue(R);
|
|
@@ -607,7 +612,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
607
612
|
min: x,
|
|
608
613
|
reverse: l,
|
|
609
614
|
step: u,
|
|
610
|
-
onChange:
|
|
615
|
+
onChange: w,
|
|
611
616
|
...n
|
|
612
617
|
}
|
|
613
618
|
);
|
|
@@ -616,7 +621,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
616
621
|
open: n,
|
|
617
622
|
onItemClick: t
|
|
618
623
|
}) => {
|
|
619
|
-
const o =
|
|
624
|
+
const o = T(), r = b(() => o == null ? void 0 : o.navigation.state$, [o]), l = b(() => o == null ? void 0 : o.settings.values$, [o]), i = (l == null ? void 0 : l.computedPageTurnDirection) === "vertical", [a, h] = y(!0);
|
|
620
625
|
return /* @__PURE__ */ e(pe, { present: n, position: "bottom", children: /* @__PURE__ */ c(P, { flex: 1, overflow: "auto", children: [
|
|
621
626
|
/* @__PURE__ */ c(O, { flex: 1, alignItems: "center", justifyContent: "center", children: [
|
|
622
627
|
/* @__PURE__ */ e(
|
|
@@ -754,7 +759,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
754
759
|
] }) });
|
|
755
760
|
}
|
|
756
761
|
), Cn = () => {
|
|
757
|
-
const [n, t] =
|
|
762
|
+
const [n, t] = y(!1), o = M(() => document.fullscreenElement ? document.exitFullscreen().catch(console.error).then(() => {
|
|
758
763
|
t(!1);
|
|
759
764
|
}) : document.documentElement.requestFullscreen({ navigationUI: "hide" }).catch(console.error).then(() => {
|
|
760
765
|
t(!0);
|
|
@@ -775,7 +780,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
775
780
|
open: n,
|
|
776
781
|
onItemClick: t
|
|
777
782
|
}) => {
|
|
778
|
-
const o =
|
|
783
|
+
const o = T(), r = b(() => o == null ? void 0 : o.context.manifest$, [o]), { isFullscreen: l, onToggleFullscreenClick: i } = Cn();
|
|
779
784
|
return /* @__PURE__ */ c(
|
|
780
785
|
pe,
|
|
781
786
|
{
|
|
@@ -893,7 +898,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
893
898
|
({
|
|
894
899
|
onNavigate: n
|
|
895
900
|
}) => {
|
|
896
|
-
const [t, o] =
|
|
901
|
+
const [t, o] = y(""), r = T(), l = ue(r) ? r : void 0, i = (d) => {
|
|
897
902
|
o(d.target.value);
|
|
898
903
|
}, a = M(
|
|
899
904
|
(d) => {
|
|
@@ -912,7 +917,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
912
917
|
);
|
|
913
918
|
return /* @__PURE__ */ c(P, { flex: 1, height: "100%", children: [
|
|
914
919
|
/* @__PURE__ */ e(A, { px: 4, children: /* @__PURE__ */ e(
|
|
915
|
-
|
|
920
|
+
ye,
|
|
916
921
|
{
|
|
917
922
|
placeholder: "Type something...",
|
|
918
923
|
value: t,
|
|
@@ -937,11 +942,11 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
937
942
|
" result(s)"
|
|
938
943
|
] }),
|
|
939
944
|
/* @__PURE__ */ e(P, { gap: 0, children: g == null ? void 0 : g.map((d, x) => {
|
|
940
|
-
var C,
|
|
945
|
+
var C, w, v, R, I, te, oe;
|
|
941
946
|
return /* @__PURE__ */ e(
|
|
942
947
|
In,
|
|
943
948
|
{
|
|
944
|
-
contextText: ((v = (
|
|
949
|
+
contextText: ((v = (w = (C = d.meta) == null ? void 0 : C.range) == null ? void 0 : w.startContainer.parentElement) == null ? void 0 : v.textContent) ?? "",
|
|
945
950
|
pageIndex: (R = d.meta) == null ? void 0 : R.itemPageIndex,
|
|
946
951
|
startOffset: ((te = (I = d.meta) == null ? void 0 : I.range) == null ? void 0 : te.startOffset) ?? 0,
|
|
947
952
|
text: t,
|
|
@@ -980,11 +985,11 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
980
985
|
] })
|
|
981
986
|
}
|
|
982
987
|
)
|
|
983
|
-
),
|
|
988
|
+
), wn = f(
|
|
984
989
|
({
|
|
985
990
|
onNavigate: n
|
|
986
991
|
}) => {
|
|
987
|
-
const t =
|
|
992
|
+
const t = T(), { manifest: o, assumedRenditionLayout: r } = b(() => t == null ? void 0 : t.context.state$, [t]) ?? {}, { nav: l } = o ?? {}, i = B();
|
|
988
993
|
l != null && l.toc;
|
|
989
994
|
const { beginSpineItemIndex: a, beginPageIndexInSpineItem: h } = i ?? {}, u = (r === "reflowable" ? h : a) || 0;
|
|
990
995
|
console.log({ assumedRenditionLayout: r, currentSpineItemOrChapterPageIndex: u });
|
|
@@ -1028,12 +1033,12 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
1028
1033
|
}
|
|
1029
1034
|
),
|
|
1030
1035
|
d.contents.length > 0 && /* @__PURE__ */ e(S.Root, { as: "div", gap: 2, children: d.contents.map(
|
|
1031
|
-
(
|
|
1036
|
+
(w, v) => g(w, v, C + 1)
|
|
1032
1037
|
) })
|
|
1033
1038
|
] }, x);
|
|
1034
1039
|
return /* @__PURE__ */ e(S.Root, { gap: 3, overflowY: "auto", py: 4, flex: 1, children: l == null ? void 0 : l.toc.map((d, x) => g(d, x, 0)) });
|
|
1035
1040
|
}
|
|
1036
|
-
),
|
|
1041
|
+
), yn = f(
|
|
1037
1042
|
({
|
|
1038
1043
|
open: n,
|
|
1039
1044
|
setOpen: t,
|
|
@@ -1049,7 +1054,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
1049
1054
|
scrollBehavior: "inside",
|
|
1050
1055
|
children: /* @__PURE__ */ c(L, { children: [
|
|
1051
1056
|
/* @__PURE__ */ e(H, { children: /* @__PURE__ */ e(V, { children: "Table of Contents" }) }),
|
|
1052
|
-
/* @__PURE__ */ e(j, { overflowY: "auto", flex: 1, children: /* @__PURE__ */ e(
|
|
1057
|
+
/* @__PURE__ */ e(j, { overflowY: "auto", flex: 1, children: /* @__PURE__ */ e(wn, { onNavigate: o }) }),
|
|
1053
1058
|
/* @__PURE__ */ e(F, { children: /* @__PURE__ */ e(Y, { asChild: !0, children: /* @__PURE__ */ e(E, { variant: "outline", children: "Cancel" }) }) }),
|
|
1054
1059
|
/* @__PURE__ */ e($, {})
|
|
1055
1060
|
] })
|
|
@@ -1060,9 +1065,9 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
1060
1065
|
enableFloatingProgress: t = !0,
|
|
1061
1066
|
onItemClick: o
|
|
1062
1067
|
}) => {
|
|
1063
|
-
const [r, l] =
|
|
1064
|
-
l(!1), a(!1), u(!1), g(!1), x(!1),
|
|
1065
|
-
}, [
|
|
1068
|
+
const [r, l] = y(!1), [i, a] = y(!1), [h, u] = y(!1), [s, g] = y(!1), [d, x] = y(!1), [C, w] = ee(), v = M(() => {
|
|
1069
|
+
l(!1), a(!1), u(!1), g(!1), x(!1), w(!1);
|
|
1070
|
+
}, [w]), R = M(
|
|
1066
1071
|
(I) => {
|
|
1067
1072
|
I === "annotations" ? g(!0) : I === "search" ? u(!0) : I === "help" ? a(!0) : I === "toc" ? l(!0) : I === "bookmarks" && x(!0), o == null || o(I);
|
|
1068
1073
|
},
|
|
@@ -1082,7 +1087,7 @@ const hn = _.Root, un = _.ValueText, ne = () => {
|
|
|
1082
1087
|
/* @__PURE__ */ e(Xe, {}),
|
|
1083
1088
|
/* @__PURE__ */ e(tn, { open: i, setOpen: a }),
|
|
1084
1089
|
/* @__PURE__ */ e(
|
|
1085
|
-
|
|
1090
|
+
yn,
|
|
1086
1091
|
{
|
|
1087
1092
|
open: r,
|
|
1088
1093
|
setOpen: l,
|