pdfjs-reader-core 0.2.8 → 0.2.10
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.cjs +337 -332
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +246 -241
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4737,7 +4737,11 @@ var init_ThumbnailPanel = __esm({
|
|
|
4737
4737
|
}
|
|
4738
4738
|
} catch (error) {
|
|
4739
4739
|
if (!cancelled) {
|
|
4740
|
-
|
|
4740
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4741
|
+
const isDocumentDestroyed = errorMessage.includes("destroyed") || errorMessage.includes("sendWithStream") || errorMessage.includes("sendWithPromise") || errorMessage.includes("Cannot read properties of null");
|
|
4742
|
+
if (!isDocumentDestroyed) {
|
|
4743
|
+
console.error(`Error rendering thumbnail for page ${pageNumber}:`, error);
|
|
4744
|
+
}
|
|
4741
4745
|
}
|
|
4742
4746
|
}
|
|
4743
4747
|
};
|
|
@@ -4777,7 +4781,7 @@ var init_ThumbnailPanel = __esm({
|
|
|
4777
4781
|
className,
|
|
4778
4782
|
thumbnailScale = 0.2
|
|
4779
4783
|
}) {
|
|
4780
|
-
const { document: document2, currentPage, numPages, goToPage
|
|
4784
|
+
const { document: document2, currentPage, numPages, goToPage } = usePDFViewer();
|
|
4781
4785
|
const containerRef = (0, import_react18.useRef)(null);
|
|
4782
4786
|
(0, import_react18.useEffect)(() => {
|
|
4783
4787
|
const container = containerRef.current;
|
|
@@ -4794,10 +4798,7 @@ var init_ThumbnailPanel = __esm({
|
|
|
4794
4798
|
[goToPage]
|
|
4795
4799
|
);
|
|
4796
4800
|
if (!document2) {
|
|
4797
|
-
|
|
4798
|
-
return null;
|
|
4799
|
-
}
|
|
4800
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cn("thumbnail-panel p-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-sm text-gray-500", children: "No document loaded" }) });
|
|
4801
|
+
return null;
|
|
4801
4802
|
}
|
|
4802
4803
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4803
4804
|
"div",
|
|
@@ -5128,7 +5129,7 @@ var init_OutlinePanel = __esm({
|
|
|
5128
5129
|
OutlinePanel = (0, import_react20.memo)(function OutlinePanel2({
|
|
5129
5130
|
className
|
|
5130
5131
|
}) {
|
|
5131
|
-
const { document: document2, goToPage
|
|
5132
|
+
const { document: document2, goToPage } = usePDFViewer();
|
|
5132
5133
|
const [outline, setOutline] = (0, import_react20.useState)(null);
|
|
5133
5134
|
const [isLoading, setIsLoading] = (0, import_react20.useState)(false);
|
|
5134
5135
|
const [error, setError] = (0, import_react20.useState)(null);
|
|
@@ -5207,10 +5208,7 @@ var init_OutlinePanel = __esm({
|
|
|
5207
5208
|
[goToPage]
|
|
5208
5209
|
);
|
|
5209
5210
|
if (!document2) {
|
|
5210
|
-
|
|
5211
|
-
return null;
|
|
5212
|
-
}
|
|
5213
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: cn("flex items-center justify-center p-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "No document loaded" }) });
|
|
5211
|
+
return null;
|
|
5214
5212
|
}
|
|
5215
5213
|
if (isLoading) {
|
|
5216
5214
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: cn("flex items-center justify-center p-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
@@ -7730,6 +7728,138 @@ var init_PDFPage2 = __esm({
|
|
|
7730
7728
|
}
|
|
7731
7729
|
});
|
|
7732
7730
|
|
|
7731
|
+
// src/components/PDFLoadingScreen/PDFLoadingScreen.tsx
|
|
7732
|
+
function formatBytes(bytes) {
|
|
7733
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
7734
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
7735
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
7736
|
+
}
|
|
7737
|
+
var import_react33, import_jsx_runtime19, phaseMessages, PDFLoadingScreen;
|
|
7738
|
+
var init_PDFLoadingScreen = __esm({
|
|
7739
|
+
"src/components/PDFLoadingScreen/PDFLoadingScreen.tsx"() {
|
|
7740
|
+
"use strict";
|
|
7741
|
+
import_react33 = require("react");
|
|
7742
|
+
init_utils();
|
|
7743
|
+
import_jsx_runtime19 = require("react/jsx-runtime");
|
|
7744
|
+
phaseMessages = {
|
|
7745
|
+
initializing: "Initializing...",
|
|
7746
|
+
fetching: "Loading document...",
|
|
7747
|
+
parsing: "Processing pages...",
|
|
7748
|
+
rendering: "Preparing view..."
|
|
7749
|
+
};
|
|
7750
|
+
PDFLoadingScreen = (0, import_react33.memo)(function PDFLoadingScreen2({
|
|
7751
|
+
progress,
|
|
7752
|
+
bytesLoaded,
|
|
7753
|
+
totalBytes,
|
|
7754
|
+
phase = "fetching",
|
|
7755
|
+
documentName,
|
|
7756
|
+
className
|
|
7757
|
+
}) {
|
|
7758
|
+
const hasProgress = progress !== void 0 && progress >= 0;
|
|
7759
|
+
const hasBytes = bytesLoaded !== void 0 && totalBytes !== void 0 && totalBytes > 0;
|
|
7760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
7761
|
+
"div",
|
|
7762
|
+
{
|
|
7763
|
+
className: cn(
|
|
7764
|
+
"pdf-loading-screen",
|
|
7765
|
+
"flex flex-col items-center justify-center",
|
|
7766
|
+
"w-full h-full min-h-[400px]",
|
|
7767
|
+
"bg-slate-50 dark:bg-slate-800",
|
|
7768
|
+
className
|
|
7769
|
+
),
|
|
7770
|
+
role: "status",
|
|
7771
|
+
"aria-live": "polite",
|
|
7772
|
+
"aria-label": phaseMessages[phase],
|
|
7773
|
+
children: [
|
|
7774
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pdf-loading-skeleton", children: [
|
|
7775
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "pdf-loading-icon", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
7776
|
+
"svg",
|
|
7777
|
+
{
|
|
7778
|
+
width: "48",
|
|
7779
|
+
height: "56",
|
|
7780
|
+
viewBox: "0 0 48 56",
|
|
7781
|
+
fill: "none",
|
|
7782
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
7783
|
+
className: "pdf-document-icon",
|
|
7784
|
+
children: [
|
|
7785
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7786
|
+
"path",
|
|
7787
|
+
{
|
|
7788
|
+
d: "M4 4C4 1.79086 5.79086 0 8 0H30L44 14V52C44 54.2091 42.2091 56 40 56H8C5.79086 56 4 54.2091 4 52V4Z",
|
|
7789
|
+
className: "fill-white dark:fill-slate-700"
|
|
7790
|
+
}
|
|
7791
|
+
),
|
|
7792
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7793
|
+
"path",
|
|
7794
|
+
{
|
|
7795
|
+
d: "M30 0L44 14H34C31.7909 14 30 12.2091 30 10V0Z",
|
|
7796
|
+
className: "fill-slate-200 dark:fill-slate-600"
|
|
7797
|
+
}
|
|
7798
|
+
),
|
|
7799
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("rect", { x: "10", y: "22", width: "24", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
7800
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("rect", { x: "10", y: "28", width: "20", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
7801
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("rect", { x: "10", y: "34", width: "22", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
7802
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("rect", { x: "10", y: "40", width: "16", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
7803
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7804
|
+
"path",
|
|
7805
|
+
{
|
|
7806
|
+
d: "M4 4C4 1.79086 5.79086 0 8 0H30L44 14V52C44 54.2091 42.2091 56 40 56H8C5.79086 56 4 54.2091 4 52V4Z",
|
|
7807
|
+
className: "stroke-slate-300 dark:stroke-slate-500",
|
|
7808
|
+
strokeWidth: "1",
|
|
7809
|
+
fill: "none"
|
|
7810
|
+
}
|
|
7811
|
+
)
|
|
7812
|
+
]
|
|
7813
|
+
}
|
|
7814
|
+
) }),
|
|
7815
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pdf-skeleton-lines", children: [
|
|
7816
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "pdf-skeleton-line pdf-skeleton-line-1" }),
|
|
7817
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "pdf-skeleton-line pdf-skeleton-line-2" }),
|
|
7818
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "pdf-skeleton-line pdf-skeleton-line-3" })
|
|
7819
|
+
] })
|
|
7820
|
+
] }),
|
|
7821
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pdf-loading-info", children: [
|
|
7822
|
+
documentName && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "pdf-loading-document-name", children: documentName }),
|
|
7823
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "pdf-loading-message", children: phaseMessages[phase] }),
|
|
7824
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pdf-loading-progress-container", children: [
|
|
7825
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "pdf-loading-progress-track", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7826
|
+
"div",
|
|
7827
|
+
{
|
|
7828
|
+
className: cn(
|
|
7829
|
+
"pdf-loading-progress-fill",
|
|
7830
|
+
!hasProgress && "pdf-loading-progress-indeterminate"
|
|
7831
|
+
),
|
|
7832
|
+
style: hasProgress ? { width: `${Math.min(100, progress)}%` } : void 0
|
|
7833
|
+
}
|
|
7834
|
+
) }),
|
|
7835
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pdf-loading-progress-details", children: [
|
|
7836
|
+
hasProgress && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "pdf-loading-progress-percent", children: [
|
|
7837
|
+
Math.round(progress),
|
|
7838
|
+
"%"
|
|
7839
|
+
] }),
|
|
7840
|
+
hasBytes && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "pdf-loading-progress-bytes", children: [
|
|
7841
|
+
formatBytes(bytesLoaded),
|
|
7842
|
+
" / ",
|
|
7843
|
+
formatBytes(totalBytes)
|
|
7844
|
+
] })
|
|
7845
|
+
] })
|
|
7846
|
+
] })
|
|
7847
|
+
] })
|
|
7848
|
+
]
|
|
7849
|
+
}
|
|
7850
|
+
);
|
|
7851
|
+
});
|
|
7852
|
+
}
|
|
7853
|
+
});
|
|
7854
|
+
|
|
7855
|
+
// src/components/PDFLoadingScreen/index.ts
|
|
7856
|
+
var init_PDFLoadingScreen2 = __esm({
|
|
7857
|
+
"src/components/PDFLoadingScreen/index.ts"() {
|
|
7858
|
+
"use strict";
|
|
7859
|
+
init_PDFLoadingScreen();
|
|
7860
|
+
}
|
|
7861
|
+
});
|
|
7862
|
+
|
|
7733
7863
|
// src/components/SelectionToolbar/SelectionToolbar.tsx
|
|
7734
7864
|
function calculatePosition(selection) {
|
|
7735
7865
|
if (!selection || selection.rects.length === 0) {
|
|
@@ -7745,13 +7875,13 @@ function calculatePosition(selection) {
|
|
|
7745
7875
|
const left = firstRect.left + firstRect.width / 2;
|
|
7746
7876
|
return { top, left, visible: true };
|
|
7747
7877
|
}
|
|
7748
|
-
var
|
|
7878
|
+
var import_react34, import_jsx_runtime20, HIGHLIGHT_COLOR_BUTTONS, SelectionToolbar;
|
|
7749
7879
|
var init_SelectionToolbar = __esm({
|
|
7750
7880
|
"src/components/SelectionToolbar/SelectionToolbar.tsx"() {
|
|
7751
7881
|
"use strict";
|
|
7752
|
-
|
|
7882
|
+
import_react34 = require("react");
|
|
7753
7883
|
init_utils();
|
|
7754
|
-
|
|
7884
|
+
import_jsx_runtime20 = require("react/jsx-runtime");
|
|
7755
7885
|
HIGHLIGHT_COLOR_BUTTONS = [
|
|
7756
7886
|
{ color: "yellow", bg: "bg-yellow-300", hoverBg: "hover:bg-yellow-400", ringColor: "ring-yellow-400" },
|
|
7757
7887
|
{ color: "green", bg: "bg-green-300", hoverBg: "hover:bg-green-400", ringColor: "ring-green-400" },
|
|
@@ -7759,16 +7889,16 @@ var init_SelectionToolbar = __esm({
|
|
|
7759
7889
|
{ color: "pink", bg: "bg-pink-300", hoverBg: "hover:bg-pink-400", ringColor: "ring-pink-400" },
|
|
7760
7890
|
{ color: "orange", bg: "bg-orange-300", hoverBg: "hover:bg-orange-400", ringColor: "ring-orange-400" }
|
|
7761
7891
|
];
|
|
7762
|
-
SelectionToolbar = (0,
|
|
7892
|
+
SelectionToolbar = (0, import_react34.memo)(function SelectionToolbar2({
|
|
7763
7893
|
selection,
|
|
7764
7894
|
onCreateHighlight,
|
|
7765
7895
|
onCopy,
|
|
7766
7896
|
activeColor = "yellow",
|
|
7767
7897
|
className
|
|
7768
7898
|
}) {
|
|
7769
|
-
const [position, setPosition] = (0,
|
|
7770
|
-
const toolbarRef = (0,
|
|
7771
|
-
(0,
|
|
7899
|
+
const [position, setPosition] = (0, import_react34.useState)({ top: 0, left: 0, visible: false });
|
|
7900
|
+
const toolbarRef = (0, import_react34.useRef)(null);
|
|
7901
|
+
(0, import_react34.useEffect)(() => {
|
|
7772
7902
|
if (selection && selection.text && selection.rects.length > 0) {
|
|
7773
7903
|
const newPosition = calculatePosition(selection);
|
|
7774
7904
|
if (toolbarRef.current && newPosition.visible) {
|
|
@@ -7796,19 +7926,19 @@ var init_SelectionToolbar = __esm({
|
|
|
7796
7926
|
setPosition({ top: 0, left: 0, visible: false });
|
|
7797
7927
|
}
|
|
7798
7928
|
}, [selection]);
|
|
7799
|
-
const handleColorClick = (0,
|
|
7929
|
+
const handleColorClick = (0, import_react34.useCallback)(
|
|
7800
7930
|
(color) => {
|
|
7801
7931
|
onCreateHighlight(color);
|
|
7802
7932
|
},
|
|
7803
7933
|
[onCreateHighlight]
|
|
7804
7934
|
);
|
|
7805
|
-
const handleCopy = (0,
|
|
7935
|
+
const handleCopy = (0, import_react34.useCallback)(() => {
|
|
7806
7936
|
onCopy?.();
|
|
7807
7937
|
}, [onCopy]);
|
|
7808
7938
|
if (!position.visible || !selection?.text) {
|
|
7809
7939
|
return null;
|
|
7810
7940
|
}
|
|
7811
|
-
return /* @__PURE__ */ (0,
|
|
7941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
7812
7942
|
"div",
|
|
7813
7943
|
{
|
|
7814
7944
|
ref: toolbarRef,
|
|
@@ -7832,7 +7962,7 @@ var init_SelectionToolbar = __esm({
|
|
|
7832
7962
|
e.stopPropagation();
|
|
7833
7963
|
},
|
|
7834
7964
|
children: [
|
|
7835
|
-
HIGHLIGHT_COLOR_BUTTONS.map((btn) => /* @__PURE__ */ (0,
|
|
7965
|
+
HIGHLIGHT_COLOR_BUTTONS.map((btn) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7836
7966
|
"button",
|
|
7837
7967
|
{
|
|
7838
7968
|
onClick: () => handleColorClick(btn.color),
|
|
@@ -7849,7 +7979,7 @@ var init_SelectionToolbar = __esm({
|
|
|
7849
7979
|
),
|
|
7850
7980
|
title: `Highlight ${btn.color}`,
|
|
7851
7981
|
"aria-label": `Highlight with ${btn.color}`,
|
|
7852
|
-
children: /* @__PURE__ */ (0,
|
|
7982
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("svg", { className: "w-4 h-4 text-gray-700", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7853
7983
|
"path",
|
|
7854
7984
|
{
|
|
7855
7985
|
strokeLinecap: "round",
|
|
@@ -7861,8 +7991,8 @@ var init_SelectionToolbar = __esm({
|
|
|
7861
7991
|
},
|
|
7862
7992
|
btn.color
|
|
7863
7993
|
)),
|
|
7864
|
-
/* @__PURE__ */ (0,
|
|
7865
|
-
/* @__PURE__ */ (0,
|
|
7994
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "w-px h-6 bg-gray-300 dark:bg-gray-600 mx-1" }),
|
|
7995
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7866
7996
|
"button",
|
|
7867
7997
|
{
|
|
7868
7998
|
onClick: handleCopy,
|
|
@@ -7874,7 +8004,7 @@ var init_SelectionToolbar = __esm({
|
|
|
7874
8004
|
),
|
|
7875
8005
|
title: "Copy text",
|
|
7876
8006
|
"aria-label": "Copy selected text",
|
|
7877
|
-
children: /* @__PURE__ */ (0,
|
|
8007
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("svg", { className: "w-5 h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
7878
8008
|
"path",
|
|
7879
8009
|
{
|
|
7880
8010
|
strokeLinecap: "round",
|
|
@@ -7914,13 +8044,13 @@ function calculatePopoverPosition(highlight, scale, pageElement) {
|
|
|
7914
8044
|
const left = scaledLeft + scaledWidth / 2;
|
|
7915
8045
|
return { top, left, visible: true };
|
|
7916
8046
|
}
|
|
7917
|
-
var
|
|
8047
|
+
var import_react35, import_jsx_runtime21, HIGHLIGHT_COLOR_OPTIONS, HighlightPopover;
|
|
7918
8048
|
var init_HighlightPopover = __esm({
|
|
7919
8049
|
"src/components/HighlightPopover/HighlightPopover.tsx"() {
|
|
7920
8050
|
"use strict";
|
|
7921
|
-
|
|
8051
|
+
import_react35 = require("react");
|
|
7922
8052
|
init_utils();
|
|
7923
|
-
|
|
8053
|
+
import_jsx_runtime21 = require("react/jsx-runtime");
|
|
7924
8054
|
HIGHLIGHT_COLOR_OPTIONS = [
|
|
7925
8055
|
{ color: "yellow", bg: "bg-yellow-300", hoverBg: "hover:bg-yellow-400", borderColor: "border-yellow-400" },
|
|
7926
8056
|
{ color: "green", bg: "bg-green-300", hoverBg: "hover:bg-green-400", borderColor: "border-green-400" },
|
|
@@ -7928,7 +8058,7 @@ var init_HighlightPopover = __esm({
|
|
|
7928
8058
|
{ color: "pink", bg: "bg-pink-300", hoverBg: "hover:bg-pink-400", borderColor: "border-pink-400" },
|
|
7929
8059
|
{ color: "orange", bg: "bg-orange-300", hoverBg: "hover:bg-orange-400", borderColor: "border-orange-400" }
|
|
7930
8060
|
];
|
|
7931
|
-
HighlightPopover = (0,
|
|
8061
|
+
HighlightPopover = (0, import_react35.memo)(function HighlightPopover2({
|
|
7932
8062
|
highlight,
|
|
7933
8063
|
scale,
|
|
7934
8064
|
pageElement,
|
|
@@ -7939,16 +8069,16 @@ var init_HighlightPopover = __esm({
|
|
|
7939
8069
|
onClose,
|
|
7940
8070
|
className
|
|
7941
8071
|
}) {
|
|
7942
|
-
const [isEditingComment, setIsEditingComment] = (0,
|
|
7943
|
-
const [comment, setComment] = (0,
|
|
7944
|
-
const [position, setPosition] = (0,
|
|
7945
|
-
const popoverRef = (0,
|
|
7946
|
-
const textareaRef = (0,
|
|
7947
|
-
(0,
|
|
8072
|
+
const [isEditingComment, setIsEditingComment] = (0, import_react35.useState)(false);
|
|
8073
|
+
const [comment, setComment] = (0, import_react35.useState)(highlight?.comment ?? "");
|
|
8074
|
+
const [position, setPosition] = (0, import_react35.useState)({ top: 0, left: 0, visible: false });
|
|
8075
|
+
const popoverRef = (0, import_react35.useRef)(null);
|
|
8076
|
+
const textareaRef = (0, import_react35.useRef)(null);
|
|
8077
|
+
(0, import_react35.useEffect)(() => {
|
|
7948
8078
|
setComment(highlight?.comment ?? "");
|
|
7949
8079
|
setIsEditingComment(false);
|
|
7950
8080
|
}, [highlight?.id, highlight?.comment]);
|
|
7951
|
-
(0,
|
|
8081
|
+
(0, import_react35.useEffect)(() => {
|
|
7952
8082
|
if (highlight && pageElement) {
|
|
7953
8083
|
const newPosition = calculatePopoverPosition(highlight, scale, pageElement);
|
|
7954
8084
|
if (newPosition.visible && popoverRef.current) {
|
|
@@ -7978,12 +8108,12 @@ var init_HighlightPopover = __esm({
|
|
|
7978
8108
|
setPosition({ top: 0, left: 0, visible: false });
|
|
7979
8109
|
}
|
|
7980
8110
|
}, [highlight, pageElement, scale, isEditingComment]);
|
|
7981
|
-
(0,
|
|
8111
|
+
(0, import_react35.useEffect)(() => {
|
|
7982
8112
|
if (isEditingComment && textareaRef.current) {
|
|
7983
8113
|
textareaRef.current.focus();
|
|
7984
8114
|
}
|
|
7985
8115
|
}, [isEditingComment]);
|
|
7986
|
-
(0,
|
|
8116
|
+
(0, import_react35.useEffect)(() => {
|
|
7987
8117
|
function handleClickOutside(event) {
|
|
7988
8118
|
if (popoverRef.current && !popoverRef.current.contains(event.target)) {
|
|
7989
8119
|
onClose();
|
|
@@ -7994,7 +8124,7 @@ var init_HighlightPopover = __esm({
|
|
|
7994
8124
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
7995
8125
|
}
|
|
7996
8126
|
}, [position.visible, onClose]);
|
|
7997
|
-
(0,
|
|
8127
|
+
(0, import_react35.useEffect)(() => {
|
|
7998
8128
|
function handleKeyDown(event) {
|
|
7999
8129
|
if (event.key === "Escape") {
|
|
8000
8130
|
if (isEditingComment) {
|
|
@@ -8010,7 +8140,7 @@ var init_HighlightPopover = __esm({
|
|
|
8010
8140
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
8011
8141
|
}
|
|
8012
8142
|
}, [position.visible, isEditingComment, highlight?.comment, onClose]);
|
|
8013
|
-
const handleColorClick = (0,
|
|
8143
|
+
const handleColorClick = (0, import_react35.useCallback)(
|
|
8014
8144
|
(color) => {
|
|
8015
8145
|
if (highlight) {
|
|
8016
8146
|
onColorChange(highlight.id, color);
|
|
@@ -8018,19 +8148,19 @@ var init_HighlightPopover = __esm({
|
|
|
8018
8148
|
},
|
|
8019
8149
|
[highlight, onColorChange]
|
|
8020
8150
|
);
|
|
8021
|
-
const handleSaveComment = (0,
|
|
8151
|
+
const handleSaveComment = (0, import_react35.useCallback)(() => {
|
|
8022
8152
|
if (highlight) {
|
|
8023
8153
|
onCommentChange(highlight.id, comment.trim());
|
|
8024
8154
|
setIsEditingComment(false);
|
|
8025
8155
|
}
|
|
8026
8156
|
}, [highlight, comment, onCommentChange]);
|
|
8027
|
-
const handleDeleteClick = (0,
|
|
8157
|
+
const handleDeleteClick = (0, import_react35.useCallback)(() => {
|
|
8028
8158
|
if (highlight) {
|
|
8029
8159
|
onDelete(highlight.id);
|
|
8030
8160
|
onClose();
|
|
8031
8161
|
}
|
|
8032
8162
|
}, [highlight, onDelete, onClose]);
|
|
8033
|
-
const handleCopyClick = (0,
|
|
8163
|
+
const handleCopyClick = (0, import_react35.useCallback)(() => {
|
|
8034
8164
|
if (highlight?.text) {
|
|
8035
8165
|
navigator.clipboard.writeText(highlight.text);
|
|
8036
8166
|
onCopy?.(highlight.text);
|
|
@@ -8039,7 +8169,7 @@ var init_HighlightPopover = __esm({
|
|
|
8039
8169
|
if (!highlight || !position.visible) {
|
|
8040
8170
|
return null;
|
|
8041
8171
|
}
|
|
8042
|
-
return /* @__PURE__ */ (0,
|
|
8172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
8043
8173
|
"div",
|
|
8044
8174
|
{
|
|
8045
8175
|
ref: popoverRef,
|
|
@@ -8059,8 +8189,8 @@ var init_HighlightPopover = __esm({
|
|
|
8059
8189
|
width: 280
|
|
8060
8190
|
},
|
|
8061
8191
|
children: [
|
|
8062
|
-
/* @__PURE__ */ (0,
|
|
8063
|
-
/* @__PURE__ */ (0,
|
|
8192
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700", children: [
|
|
8193
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex items-center gap-1", children: HIGHLIGHT_COLOR_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8064
8194
|
"button",
|
|
8065
8195
|
{
|
|
8066
8196
|
onClick: () => handleColorClick(opt.color),
|
|
@@ -8078,7 +8208,7 @@ var init_HighlightPopover = __esm({
|
|
|
8078
8208
|
},
|
|
8079
8209
|
opt.color
|
|
8080
8210
|
)) }),
|
|
8081
|
-
/* @__PURE__ */ (0,
|
|
8211
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8082
8212
|
"button",
|
|
8083
8213
|
{
|
|
8084
8214
|
onClick: handleDeleteClick,
|
|
@@ -8090,7 +8220,7 @@ var init_HighlightPopover = __esm({
|
|
|
8090
8220
|
),
|
|
8091
8221
|
title: "Delete highlight",
|
|
8092
8222
|
"aria-label": "Delete highlight",
|
|
8093
|
-
children: /* @__PURE__ */ (0,
|
|
8223
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8094
8224
|
"path",
|
|
8095
8225
|
{
|
|
8096
8226
|
strokeLinecap: "round",
|
|
@@ -8102,8 +8232,8 @@ var init_HighlightPopover = __esm({
|
|
|
8102
8232
|
}
|
|
8103
8233
|
)
|
|
8104
8234
|
] }),
|
|
8105
|
-
/* @__PURE__ */ (0,
|
|
8106
|
-
/* @__PURE__ */ (0,
|
|
8235
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "p-2", children: isEditingComment ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
8236
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8107
8237
|
"textarea",
|
|
8108
8238
|
{
|
|
8109
8239
|
ref: textareaRef,
|
|
@@ -8122,8 +8252,8 @@ var init_HighlightPopover = __esm({
|
|
|
8122
8252
|
rows: 3
|
|
8123
8253
|
}
|
|
8124
8254
|
),
|
|
8125
|
-
/* @__PURE__ */ (0,
|
|
8126
|
-
/* @__PURE__ */ (0,
|
|
8255
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
8256
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8127
8257
|
"button",
|
|
8128
8258
|
{
|
|
8129
8259
|
onClick: () => {
|
|
@@ -8139,7 +8269,7 @@ var init_HighlightPopover = __esm({
|
|
|
8139
8269
|
children: "Cancel"
|
|
8140
8270
|
}
|
|
8141
8271
|
),
|
|
8142
|
-
/* @__PURE__ */ (0,
|
|
8272
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8143
8273
|
"button",
|
|
8144
8274
|
{
|
|
8145
8275
|
onClick: handleSaveComment,
|
|
@@ -8153,14 +8283,14 @@ var init_HighlightPopover = __esm({
|
|
|
8153
8283
|
}
|
|
8154
8284
|
)
|
|
8155
8285
|
] })
|
|
8156
|
-
] }) : /* @__PURE__ */ (0,
|
|
8157
|
-
/* @__PURE__ */ (0,
|
|
8286
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
8287
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { className: "text-xs text-gray-500 dark:text-gray-400 line-clamp-2", children: [
|
|
8158
8288
|
"\u201C",
|
|
8159
8289
|
highlight.text.slice(0, 100),
|
|
8160
8290
|
highlight.text.length > 100 ? "..." : "",
|
|
8161
8291
|
"\u201D"
|
|
8162
8292
|
] }),
|
|
8163
|
-
highlight.comment ? /* @__PURE__ */ (0,
|
|
8293
|
+
highlight.comment ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8164
8294
|
"button",
|
|
8165
8295
|
{
|
|
8166
8296
|
onClick: () => setIsEditingComment(true),
|
|
@@ -8173,7 +8303,7 @@ var init_HighlightPopover = __esm({
|
|
|
8173
8303
|
),
|
|
8174
8304
|
children: highlight.comment
|
|
8175
8305
|
}
|
|
8176
|
-
) : /* @__PURE__ */ (0,
|
|
8306
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8177
8307
|
"button",
|
|
8178
8308
|
{
|
|
8179
8309
|
onClick: () => setIsEditingComment(true),
|
|
@@ -8186,7 +8316,7 @@ var init_HighlightPopover = __esm({
|
|
|
8186
8316
|
children: "+ Add a note..."
|
|
8187
8317
|
}
|
|
8188
8318
|
),
|
|
8189
|
-
/* @__PURE__ */ (0,
|
|
8319
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
8190
8320
|
"button",
|
|
8191
8321
|
{
|
|
8192
8322
|
onClick: handleCopyClick,
|
|
@@ -8197,7 +8327,7 @@ var init_HighlightPopover = __esm({
|
|
|
8197
8327
|
"focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
8198
8328
|
),
|
|
8199
8329
|
children: [
|
|
8200
|
-
/* @__PURE__ */ (0,
|
|
8330
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8201
8331
|
"path",
|
|
8202
8332
|
{
|
|
8203
8333
|
strokeLinecap: "round",
|
|
@@ -8227,19 +8357,20 @@ var init_HighlightPopover2 = __esm({
|
|
|
8227
8357
|
});
|
|
8228
8358
|
|
|
8229
8359
|
// src/components/PDFViewer/DocumentContainer.tsx
|
|
8230
|
-
var
|
|
8360
|
+
var import_react36, import_jsx_runtime22, DocumentContainer;
|
|
8231
8361
|
var init_DocumentContainer = __esm({
|
|
8232
8362
|
"src/components/PDFViewer/DocumentContainer.tsx"() {
|
|
8233
8363
|
"use strict";
|
|
8234
|
-
|
|
8364
|
+
import_react36 = require("react");
|
|
8235
8365
|
init_PDFPage2();
|
|
8366
|
+
init_PDFLoadingScreen2();
|
|
8236
8367
|
init_hooks();
|
|
8237
8368
|
init_useHighlights();
|
|
8238
8369
|
init_SelectionToolbar2();
|
|
8239
8370
|
init_HighlightPopover2();
|
|
8240
8371
|
init_utils();
|
|
8241
|
-
|
|
8242
|
-
DocumentContainer = (0,
|
|
8372
|
+
import_jsx_runtime22 = require("react/jsx-runtime");
|
|
8373
|
+
DocumentContainer = (0, import_react36.memo)(function DocumentContainer2({
|
|
8243
8374
|
className,
|
|
8244
8375
|
enableTouchGestures = true
|
|
8245
8376
|
}) {
|
|
@@ -8256,34 +8387,34 @@ var init_DocumentContainer = __esm({
|
|
|
8256
8387
|
} = usePDFViewer();
|
|
8257
8388
|
const scrollToPageRequest = useViewerStore((s) => s.scrollToPageRequest);
|
|
8258
8389
|
const { viewerStore } = usePDFViewerStores();
|
|
8259
|
-
const [currentPageObj, setCurrentPageObj] = (0,
|
|
8260
|
-
const [isLoadingPage, setIsLoadingPage] = (0,
|
|
8261
|
-
const containerRef = (0,
|
|
8262
|
-
const documentRef = (0,
|
|
8263
|
-
const baseScaleRef = (0,
|
|
8390
|
+
const [currentPageObj, setCurrentPageObj] = (0, import_react36.useState)(null);
|
|
8391
|
+
const [isLoadingPage, setIsLoadingPage] = (0, import_react36.useState)(false);
|
|
8392
|
+
const containerRef = (0, import_react36.useRef)(null);
|
|
8393
|
+
const documentRef = (0, import_react36.useRef)(null);
|
|
8394
|
+
const baseScaleRef = (0, import_react36.useRef)(scale);
|
|
8264
8395
|
const isTouchDevice = useIsTouchDevice();
|
|
8265
8396
|
const { selection, clearSelection, copySelection } = useTextSelection();
|
|
8266
|
-
const handlePinchZoom = (0,
|
|
8397
|
+
const handlePinchZoom = (0, import_react36.useCallback)(
|
|
8267
8398
|
(pinchScale) => {
|
|
8268
8399
|
const newScale = Math.max(0.25, Math.min(4, baseScaleRef.current * pinchScale));
|
|
8269
8400
|
setScale(newScale);
|
|
8270
8401
|
},
|
|
8271
8402
|
[setScale]
|
|
8272
8403
|
);
|
|
8273
|
-
const handleSwipeLeft = (0,
|
|
8404
|
+
const handleSwipeLeft = (0, import_react36.useCallback)(() => {
|
|
8274
8405
|
nextPage();
|
|
8275
8406
|
}, [nextPage]);
|
|
8276
|
-
const handleSwipeRight = (0,
|
|
8407
|
+
const handleSwipeRight = (0, import_react36.useCallback)(() => {
|
|
8277
8408
|
previousPage();
|
|
8278
8409
|
}, [previousPage]);
|
|
8279
|
-
const handleDoubleTap = (0,
|
|
8410
|
+
const handleDoubleTap = (0, import_react36.useCallback)(
|
|
8280
8411
|
(_position) => {
|
|
8281
8412
|
const newScale = scale < 1.5 ? 2 : 1;
|
|
8282
8413
|
setScale(newScale);
|
|
8283
8414
|
},
|
|
8284
8415
|
[scale, setScale]
|
|
8285
8416
|
);
|
|
8286
|
-
(0,
|
|
8417
|
+
(0, import_react36.useEffect)(() => {
|
|
8287
8418
|
baseScaleRef.current = scale;
|
|
8288
8419
|
}, [scale]);
|
|
8289
8420
|
const { ref: touchRef } = useTouchGestures({
|
|
@@ -8303,13 +8434,13 @@ var init_DocumentContainer = __esm({
|
|
|
8303
8434
|
selectHighlight,
|
|
8304
8435
|
activeColor
|
|
8305
8436
|
} = useHighlights();
|
|
8306
|
-
(0,
|
|
8437
|
+
(0, import_react36.useEffect)(() => {
|
|
8307
8438
|
if (document2 !== documentRef.current) {
|
|
8308
8439
|
documentRef.current = document2;
|
|
8309
8440
|
setCurrentPageObj(null);
|
|
8310
8441
|
}
|
|
8311
8442
|
}, [document2]);
|
|
8312
|
-
(0,
|
|
8443
|
+
(0, import_react36.useEffect)(() => {
|
|
8313
8444
|
if (!document2) {
|
|
8314
8445
|
setCurrentPageObj(null);
|
|
8315
8446
|
return;
|
|
@@ -8330,7 +8461,8 @@ var init_DocumentContainer = __esm({
|
|
|
8330
8461
|
} catch (error) {
|
|
8331
8462
|
if (!cancelled) {
|
|
8332
8463
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
8333
|
-
|
|
8464
|
+
const isDocumentDestroyed = errorMessage.includes("destroyed") || errorMessage.includes("sendWithStream") || errorMessage.includes("sendWithPromise") || errorMessage.includes("Cannot read properties of null");
|
|
8465
|
+
if (!isDocumentDestroyed) {
|
|
8334
8466
|
console.error("Error loading page:", error);
|
|
8335
8467
|
}
|
|
8336
8468
|
}
|
|
@@ -8345,10 +8477,10 @@ var init_DocumentContainer = __esm({
|
|
|
8345
8477
|
cancelled = true;
|
|
8346
8478
|
};
|
|
8347
8479
|
}, [document2, currentPage, scrollToPageRequest, viewerStore]);
|
|
8348
|
-
const getPageElement = (0,
|
|
8480
|
+
const getPageElement = (0, import_react36.useCallback)(() => {
|
|
8349
8481
|
return containerRef.current?.querySelector(`[data-page-number="${currentPage}"]`);
|
|
8350
8482
|
}, [currentPage]);
|
|
8351
|
-
const handleCreateHighlight = (0,
|
|
8483
|
+
const handleCreateHighlight = (0, import_react36.useCallback)(
|
|
8352
8484
|
(color) => {
|
|
8353
8485
|
if (!selection) return;
|
|
8354
8486
|
const pageElement = getPageElement();
|
|
@@ -8358,25 +8490,25 @@ var init_DocumentContainer = __esm({
|
|
|
8358
8490
|
},
|
|
8359
8491
|
[selection, getPageElement, createHighlightFromSelection, scale, clearSelection]
|
|
8360
8492
|
);
|
|
8361
|
-
const handleCopySelection = (0,
|
|
8493
|
+
const handleCopySelection = (0, import_react36.useCallback)(() => {
|
|
8362
8494
|
copySelection();
|
|
8363
8495
|
}, [copySelection]);
|
|
8364
|
-
const handleColorChange = (0,
|
|
8496
|
+
const handleColorChange = (0, import_react36.useCallback)(
|
|
8365
8497
|
(id, color) => {
|
|
8366
8498
|
updateHighlight(id, { color });
|
|
8367
8499
|
},
|
|
8368
8500
|
[updateHighlight]
|
|
8369
8501
|
);
|
|
8370
|
-
const handleCommentChange = (0,
|
|
8502
|
+
const handleCommentChange = (0, import_react36.useCallback)(
|
|
8371
8503
|
(id, comment) => {
|
|
8372
8504
|
updateHighlight(id, { comment: comment || void 0 });
|
|
8373
8505
|
},
|
|
8374
8506
|
[updateHighlight]
|
|
8375
8507
|
);
|
|
8376
|
-
const handleClosePopover = (0,
|
|
8508
|
+
const handleClosePopover = (0, import_react36.useCallback)(() => {
|
|
8377
8509
|
selectHighlight(null);
|
|
8378
8510
|
}, [selectHighlight]);
|
|
8379
|
-
const setContainerRef = (0,
|
|
8511
|
+
const setContainerRef = (0, import_react36.useCallback)(
|
|
8380
8512
|
(element) => {
|
|
8381
8513
|
containerRef.current = element;
|
|
8382
8514
|
touchRef(element);
|
|
@@ -8389,23 +8521,20 @@ var init_DocumentContainer = __esm({
|
|
|
8389
8521
|
sepia: "bg-amber-50"
|
|
8390
8522
|
};
|
|
8391
8523
|
if (!document2) {
|
|
8392
|
-
|
|
8393
|
-
return null;
|
|
8394
|
-
}
|
|
8395
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8396
8525
|
"div",
|
|
8397
8526
|
{
|
|
8398
8527
|
className: cn(
|
|
8399
8528
|
"document-container",
|
|
8400
|
-
"flex-1
|
|
8529
|
+
"flex-1",
|
|
8401
8530
|
themeStyles[theme],
|
|
8402
8531
|
className
|
|
8403
8532
|
),
|
|
8404
|
-
children: /* @__PURE__ */ (0,
|
|
8533
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PDFLoadingScreen, { phase: isLoading ? "fetching" : "initializing" })
|
|
8405
8534
|
}
|
|
8406
8535
|
);
|
|
8407
8536
|
}
|
|
8408
|
-
return /* @__PURE__ */ (0,
|
|
8537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
8409
8538
|
"div",
|
|
8410
8539
|
{
|
|
8411
8540
|
ref: setContainerRef,
|
|
@@ -8418,7 +8547,7 @@ var init_DocumentContainer = __esm({
|
|
|
8418
8547
|
className
|
|
8419
8548
|
),
|
|
8420
8549
|
children: [
|
|
8421
|
-
/* @__PURE__ */ (0,
|
|
8550
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8422
8551
|
PDFPage,
|
|
8423
8552
|
{
|
|
8424
8553
|
pageNumber: currentPage,
|
|
@@ -8427,7 +8556,7 @@ var init_DocumentContainer = __esm({
|
|
|
8427
8556
|
rotation
|
|
8428
8557
|
}
|
|
8429
8558
|
),
|
|
8430
|
-
/* @__PURE__ */ (0,
|
|
8559
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8431
8560
|
SelectionToolbar,
|
|
8432
8561
|
{
|
|
8433
8562
|
selection,
|
|
@@ -8436,7 +8565,7 @@ var init_DocumentContainer = __esm({
|
|
|
8436
8565
|
activeColor
|
|
8437
8566
|
}
|
|
8438
8567
|
),
|
|
8439
|
-
/* @__PURE__ */ (0,
|
|
8568
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8440
8569
|
HighlightPopover,
|
|
8441
8570
|
{
|
|
8442
8571
|
highlight: selectedHighlight,
|
|
@@ -8448,7 +8577,7 @@ var init_DocumentContainer = __esm({
|
|
|
8448
8577
|
onClose: handleClosePopover
|
|
8449
8578
|
}
|
|
8450
8579
|
),
|
|
8451
|
-
isLoadingPage && !currentPageObj && /* @__PURE__ */ (0,
|
|
8580
|
+
isLoadingPage && !currentPageObj && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "fixed bottom-4 right-4 px-3 py-2 bg-black/75 text-white text-sm rounded-lg", children: "Loading..." })
|
|
8452
8581
|
]
|
|
8453
8582
|
}
|
|
8454
8583
|
);
|
|
@@ -8457,21 +8586,22 @@ var init_DocumentContainer = __esm({
|
|
|
8457
8586
|
});
|
|
8458
8587
|
|
|
8459
8588
|
// src/components/PDFViewer/VirtualizedDocumentContainer.tsx
|
|
8460
|
-
var
|
|
8589
|
+
var import_react37, import_jsx_runtime23, DEFAULT_PAGE_WIDTH, DEFAULT_PAGE_HEIGHT, VirtualizedDocumentContainer;
|
|
8461
8590
|
var init_VirtualizedDocumentContainer = __esm({
|
|
8462
8591
|
"src/components/PDFViewer/VirtualizedDocumentContainer.tsx"() {
|
|
8463
8592
|
"use strict";
|
|
8464
|
-
|
|
8593
|
+
import_react37 = require("react");
|
|
8465
8594
|
init_PDFPage2();
|
|
8595
|
+
init_PDFLoadingScreen2();
|
|
8466
8596
|
init_hooks();
|
|
8467
8597
|
init_useHighlights();
|
|
8468
8598
|
init_SelectionToolbar2();
|
|
8469
8599
|
init_HighlightPopover2();
|
|
8470
8600
|
init_utils();
|
|
8471
|
-
|
|
8601
|
+
import_jsx_runtime23 = require("react/jsx-runtime");
|
|
8472
8602
|
DEFAULT_PAGE_WIDTH = 612;
|
|
8473
8603
|
DEFAULT_PAGE_HEIGHT = 792;
|
|
8474
|
-
VirtualizedDocumentContainer = (0,
|
|
8604
|
+
VirtualizedDocumentContainer = (0, import_react37.memo)(function VirtualizedDocumentContainer2({
|
|
8475
8605
|
overscan = 2,
|
|
8476
8606
|
pageGap = 16,
|
|
8477
8607
|
enableTouchGestures = true,
|
|
@@ -8492,17 +8622,17 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8492
8622
|
} = usePDFViewer();
|
|
8493
8623
|
const scrollToPageRequest = useViewerStore((s) => s.scrollToPageRequest);
|
|
8494
8624
|
const { viewerStore } = usePDFViewerStores();
|
|
8495
|
-
const containerRef = (0,
|
|
8496
|
-
const scrollContainerRef = (0,
|
|
8497
|
-
const documentRef = (0,
|
|
8498
|
-
const pageCache = (0,
|
|
8499
|
-
const pageDimensionsCache = (0,
|
|
8500
|
-
const baseScaleRef = (0,
|
|
8625
|
+
const containerRef = (0, import_react37.useRef)(null);
|
|
8626
|
+
const scrollContainerRef = (0, import_react37.useRef)(null);
|
|
8627
|
+
const documentRef = (0, import_react37.useRef)(null);
|
|
8628
|
+
const pageCache = (0, import_react37.useRef)(/* @__PURE__ */ new Map());
|
|
8629
|
+
const pageDimensionsCache = (0, import_react37.useRef)(/* @__PURE__ */ new Map());
|
|
8630
|
+
const baseScaleRef = (0, import_react37.useRef)(scale);
|
|
8501
8631
|
const isTouchDevice = useIsTouchDevice();
|
|
8502
|
-
const [visiblePages, setVisiblePages] = (0,
|
|
8503
|
-
const [pageObjects, setPageObjects] = (0,
|
|
8504
|
-
const [totalHeight, setTotalHeight] = (0,
|
|
8505
|
-
const [pageInfos, setPageInfos] = (0,
|
|
8632
|
+
const [visiblePages, setVisiblePages] = (0, import_react37.useState)([1]);
|
|
8633
|
+
const [pageObjects, setPageObjects] = (0, import_react37.useState)(/* @__PURE__ */ new Map());
|
|
8634
|
+
const [totalHeight, setTotalHeight] = (0, import_react37.useState)(0);
|
|
8635
|
+
const [pageInfos, setPageInfos] = (0, import_react37.useState)([]);
|
|
8506
8636
|
const { selection, clearSelection, copySelection } = useTextSelection();
|
|
8507
8637
|
const {
|
|
8508
8638
|
createHighlightFromSelection,
|
|
@@ -8512,7 +8642,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8512
8642
|
selectHighlight,
|
|
8513
8643
|
activeColor
|
|
8514
8644
|
} = useHighlights();
|
|
8515
|
-
(0,
|
|
8645
|
+
(0, import_react37.useEffect)(() => {
|
|
8516
8646
|
if (document2 !== documentRef.current) {
|
|
8517
8647
|
documentRef.current = document2;
|
|
8518
8648
|
pageCache.current.clear();
|
|
@@ -8520,7 +8650,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8520
8650
|
setPageObjects(/* @__PURE__ */ new Map());
|
|
8521
8651
|
}
|
|
8522
8652
|
}, [document2]);
|
|
8523
|
-
(0,
|
|
8653
|
+
(0, import_react37.useEffect)(() => {
|
|
8524
8654
|
if (!document2 || numPages === 0) return;
|
|
8525
8655
|
const calculatePageInfos = async () => {
|
|
8526
8656
|
const infos = [];
|
|
@@ -8553,7 +8683,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8553
8683
|
};
|
|
8554
8684
|
calculatePageInfos();
|
|
8555
8685
|
}, [document2, numPages, scale, rotation, pageGap]);
|
|
8556
|
-
const updateVisiblePages = (0,
|
|
8686
|
+
const updateVisiblePages = (0, import_react37.useCallback)(() => {
|
|
8557
8687
|
if (!scrollContainerRef.current || pageInfos.length === 0) return;
|
|
8558
8688
|
const container = scrollContainerRef.current;
|
|
8559
8689
|
const scrollTop = container.scrollTop;
|
|
@@ -8585,7 +8715,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8585
8715
|
goToPage(firstVisiblePage);
|
|
8586
8716
|
}
|
|
8587
8717
|
}, [pageInfos, overscan, currentPage, goToPage]);
|
|
8588
|
-
(0,
|
|
8718
|
+
(0, import_react37.useEffect)(() => {
|
|
8589
8719
|
const container = scrollContainerRef.current;
|
|
8590
8720
|
if (!container) return;
|
|
8591
8721
|
const handleScroll = () => {
|
|
@@ -8595,7 +8725,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8595
8725
|
updateVisiblePages();
|
|
8596
8726
|
return () => container.removeEventListener("scroll", handleScroll);
|
|
8597
8727
|
}, [updateVisiblePages]);
|
|
8598
|
-
(0,
|
|
8728
|
+
(0, import_react37.useEffect)(() => {
|
|
8599
8729
|
if (!document2) return;
|
|
8600
8730
|
const loadPages = async () => {
|
|
8601
8731
|
const newPageObjects = new Map(pageObjects);
|
|
@@ -8611,7 +8741,11 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8611
8741
|
newPageObjects.set(pageNum, page);
|
|
8612
8742
|
hasChanges = true;
|
|
8613
8743
|
} catch (error) {
|
|
8614
|
-
|
|
8744
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
8745
|
+
const isDocumentDestroyed = errorMessage.includes("destroyed") || errorMessage.includes("sendWithStream") || errorMessage.includes("sendWithPromise") || errorMessage.includes("Cannot read properties of null");
|
|
8746
|
+
if (!isDocumentDestroyed) {
|
|
8747
|
+
console.error(`Error loading page ${pageNum}:`, error);
|
|
8748
|
+
}
|
|
8615
8749
|
}
|
|
8616
8750
|
}
|
|
8617
8751
|
}
|
|
@@ -8628,7 +8762,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8628
8762
|
};
|
|
8629
8763
|
loadPages();
|
|
8630
8764
|
}, [document2, visiblePages, pageObjects]);
|
|
8631
|
-
(0,
|
|
8765
|
+
(0, import_react37.useEffect)(() => {
|
|
8632
8766
|
if (!scrollToPageRequest || !scrollContainerRef.current || pageInfos.length === 0) return;
|
|
8633
8767
|
const { page, requestId, behavior } = scrollToPageRequest;
|
|
8634
8768
|
const pageInfo = pageInfos.find((p) => p.pageNumber === page);
|
|
@@ -8666,7 +8800,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8666
8800
|
handleScrollEnd();
|
|
8667
8801
|
}
|
|
8668
8802
|
}, [scrollToPageRequest, pageInfos, pageGap, viewerStore]);
|
|
8669
|
-
(0,
|
|
8803
|
+
(0, import_react37.useEffect)(() => {
|
|
8670
8804
|
if (scrollToPageRequest) return;
|
|
8671
8805
|
if (!scrollContainerRef.current || pageInfos.length === 0) return;
|
|
8672
8806
|
const pageInfo = pageInfos.find((p) => p.pageNumber === currentPage);
|
|
@@ -8683,14 +8817,14 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8683
8817
|
}
|
|
8684
8818
|
}
|
|
8685
8819
|
}, [currentPage, pageInfos, pageGap, scrollToPageRequest]);
|
|
8686
|
-
const handlePinchZoom = (0,
|
|
8820
|
+
const handlePinchZoom = (0, import_react37.useCallback)(
|
|
8687
8821
|
(pinchScale) => {
|
|
8688
8822
|
const newScale = Math.max(0.25, Math.min(4, baseScaleRef.current * pinchScale));
|
|
8689
8823
|
setScale(newScale);
|
|
8690
8824
|
},
|
|
8691
8825
|
[setScale]
|
|
8692
8826
|
);
|
|
8693
|
-
(0,
|
|
8827
|
+
(0, import_react37.useEffect)(() => {
|
|
8694
8828
|
baseScaleRef.current = scale;
|
|
8695
8829
|
}, [scale]);
|
|
8696
8830
|
const { ref: touchRef } = useTouchGestures({
|
|
@@ -8699,20 +8833,20 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8699
8833
|
onSwipeRight: previousPage,
|
|
8700
8834
|
enabled: enableTouchGestures && isTouchDevice
|
|
8701
8835
|
});
|
|
8702
|
-
const setContainerRef = (0,
|
|
8836
|
+
const setContainerRef = (0, import_react37.useCallback)(
|
|
8703
8837
|
(element) => {
|
|
8704
8838
|
scrollContainerRef.current = element;
|
|
8705
8839
|
touchRef(element);
|
|
8706
8840
|
},
|
|
8707
8841
|
[touchRef]
|
|
8708
8842
|
);
|
|
8709
|
-
const getPageElement = (0,
|
|
8843
|
+
const getPageElement = (0, import_react37.useCallback)(
|
|
8710
8844
|
(pageNumber) => {
|
|
8711
8845
|
return containerRef.current?.querySelector(`[data-page-number="${pageNumber}"]`);
|
|
8712
8846
|
},
|
|
8713
8847
|
[]
|
|
8714
8848
|
);
|
|
8715
|
-
const handleCreateHighlight = (0,
|
|
8849
|
+
const handleCreateHighlight = (0, import_react37.useCallback)(
|
|
8716
8850
|
(color) => {
|
|
8717
8851
|
if (!selection) return;
|
|
8718
8852
|
const pageElement = getPageElement(selection.pageNumber);
|
|
@@ -8722,13 +8856,13 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8722
8856
|
},
|
|
8723
8857
|
[selection, getPageElement, createHighlightFromSelection, scale, clearSelection]
|
|
8724
8858
|
);
|
|
8725
|
-
const handleColorChange = (0,
|
|
8859
|
+
const handleColorChange = (0, import_react37.useCallback)(
|
|
8726
8860
|
(id, color) => {
|
|
8727
8861
|
updateHighlight(id, { color });
|
|
8728
8862
|
},
|
|
8729
8863
|
[updateHighlight]
|
|
8730
8864
|
);
|
|
8731
|
-
const handleCommentChange = (0,
|
|
8865
|
+
const handleCommentChange = (0, import_react37.useCallback)(
|
|
8732
8866
|
(id, comment) => {
|
|
8733
8867
|
updateHighlight(id, { comment: comment || void 0 });
|
|
8734
8868
|
},
|
|
@@ -8740,23 +8874,20 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8740
8874
|
sepia: "bg-amber-50"
|
|
8741
8875
|
};
|
|
8742
8876
|
if (!document2) {
|
|
8743
|
-
|
|
8744
|
-
return null;
|
|
8745
|
-
}
|
|
8746
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8747
8878
|
"div",
|
|
8748
8879
|
{
|
|
8749
8880
|
className: cn(
|
|
8750
8881
|
"virtualized-document-container",
|
|
8751
|
-
"flex-1
|
|
8882
|
+
"flex-1",
|
|
8752
8883
|
themeStyles[theme],
|
|
8753
8884
|
className
|
|
8754
8885
|
),
|
|
8755
|
-
children: /* @__PURE__ */ (0,
|
|
8886
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PDFLoadingScreen, { phase: isLoading ? "fetching" : "initializing" })
|
|
8756
8887
|
}
|
|
8757
8888
|
);
|
|
8758
8889
|
}
|
|
8759
|
-
return /* @__PURE__ */ (0,
|
|
8890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
8760
8891
|
"div",
|
|
8761
8892
|
{
|
|
8762
8893
|
ref: containerRef,
|
|
@@ -8767,7 +8898,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8767
8898
|
className
|
|
8768
8899
|
),
|
|
8769
8900
|
children: [
|
|
8770
|
-
/* @__PURE__ */ (0,
|
|
8901
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8771
8902
|
"div",
|
|
8772
8903
|
{
|
|
8773
8904
|
ref: setContainerRef,
|
|
@@ -8776,7 +8907,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8776
8907
|
// Smooth scrolling on iOS
|
|
8777
8908
|
WebkitOverflowScrolling: "touch"
|
|
8778
8909
|
},
|
|
8779
|
-
children: /* @__PURE__ */ (0,
|
|
8910
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8780
8911
|
"div",
|
|
8781
8912
|
{
|
|
8782
8913
|
className: "relative mx-auto",
|
|
@@ -8788,7 +8919,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8788
8919
|
const page = pageObjects.get(info.pageNumber);
|
|
8789
8920
|
const dimensions = pageDimensionsCache.current.get(info.pageNumber);
|
|
8790
8921
|
const scaledWidth = dimensions ? Math.floor(dimensions.width * scale) : Math.floor(DEFAULT_PAGE_WIDTH * scale);
|
|
8791
|
-
return /* @__PURE__ */ (0,
|
|
8922
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8792
8923
|
"div",
|
|
8793
8924
|
{
|
|
8794
8925
|
className: "absolute left-1/2 -translate-x-1/2",
|
|
@@ -8796,7 +8927,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8796
8927
|
top: info.top,
|
|
8797
8928
|
width: scaledWidth
|
|
8798
8929
|
},
|
|
8799
|
-
children: /* @__PURE__ */ (0,
|
|
8930
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8800
8931
|
PDFPage,
|
|
8801
8932
|
{
|
|
8802
8933
|
pageNumber: info.pageNumber,
|
|
@@ -8813,7 +8944,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8813
8944
|
)
|
|
8814
8945
|
}
|
|
8815
8946
|
),
|
|
8816
|
-
/* @__PURE__ */ (0,
|
|
8947
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8817
8948
|
SelectionToolbar,
|
|
8818
8949
|
{
|
|
8819
8950
|
selection,
|
|
@@ -8822,7 +8953,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8822
8953
|
activeColor
|
|
8823
8954
|
}
|
|
8824
8955
|
),
|
|
8825
|
-
/* @__PURE__ */ (0,
|
|
8956
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8826
8957
|
HighlightPopover,
|
|
8827
8958
|
{
|
|
8828
8959
|
highlight: selectedHighlight,
|
|
@@ -8842,15 +8973,15 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8842
8973
|
});
|
|
8843
8974
|
|
|
8844
8975
|
// src/components/PDFViewer/ContinuousScrollContainer.tsx
|
|
8845
|
-
var
|
|
8976
|
+
var import_react38, import_jsx_runtime24, ContinuousScrollContainer;
|
|
8846
8977
|
var init_ContinuousScrollContainer = __esm({
|
|
8847
8978
|
"src/components/PDFViewer/ContinuousScrollContainer.tsx"() {
|
|
8848
8979
|
"use strict";
|
|
8849
|
-
|
|
8980
|
+
import_react38 = require("react");
|
|
8850
8981
|
init_VirtualizedDocumentContainer();
|
|
8851
|
-
|
|
8852
|
-
ContinuousScrollContainer = (0,
|
|
8853
|
-
return /* @__PURE__ */ (0,
|
|
8982
|
+
import_jsx_runtime24 = require("react/jsx-runtime");
|
|
8983
|
+
ContinuousScrollContainer = (0, import_react38.memo)(function ContinuousScrollContainer2(props) {
|
|
8984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
8854
8985
|
VirtualizedDocumentContainer,
|
|
8855
8986
|
{
|
|
8856
8987
|
overscan: 3,
|
|
@@ -8863,19 +8994,20 @@ var init_ContinuousScrollContainer = __esm({
|
|
|
8863
8994
|
});
|
|
8864
8995
|
|
|
8865
8996
|
// src/components/PDFViewer/DualPageContainer.tsx
|
|
8866
|
-
var
|
|
8997
|
+
var import_react39, import_jsx_runtime25, DualPageContainer;
|
|
8867
8998
|
var init_DualPageContainer = __esm({
|
|
8868
8999
|
"src/components/PDFViewer/DualPageContainer.tsx"() {
|
|
8869
9000
|
"use strict";
|
|
8870
|
-
|
|
9001
|
+
import_react39 = require("react");
|
|
8871
9002
|
init_PDFPage2();
|
|
9003
|
+
init_PDFLoadingScreen2();
|
|
8872
9004
|
init_hooks();
|
|
8873
9005
|
init_useHighlights();
|
|
8874
9006
|
init_SelectionToolbar2();
|
|
8875
9007
|
init_HighlightPopover2();
|
|
8876
9008
|
init_utils();
|
|
8877
|
-
|
|
8878
|
-
DualPageContainer = (0,
|
|
9009
|
+
import_jsx_runtime25 = require("react/jsx-runtime");
|
|
9010
|
+
DualPageContainer = (0, import_react39.memo)(function DualPageContainer2({
|
|
8879
9011
|
showCover = true,
|
|
8880
9012
|
bookSpread = true,
|
|
8881
9013
|
pageGap = 4,
|
|
@@ -8895,13 +9027,13 @@ var init_DualPageContainer = __esm({
|
|
|
8895
9027
|
} = usePDFViewer();
|
|
8896
9028
|
const scrollToPageRequest = useViewerStore((s) => s.scrollToPageRequest);
|
|
8897
9029
|
const { viewerStore } = usePDFViewerStores();
|
|
8898
|
-
const containerRef = (0,
|
|
8899
|
-
const documentRef = (0,
|
|
8900
|
-
const baseScaleRef = (0,
|
|
9030
|
+
const containerRef = (0, import_react39.useRef)(null);
|
|
9031
|
+
const documentRef = (0, import_react39.useRef)(null);
|
|
9032
|
+
const baseScaleRef = (0, import_react39.useRef)(scale);
|
|
8901
9033
|
const isTouchDevice = useIsTouchDevice();
|
|
8902
|
-
const [leftPage, setLeftPage] = (0,
|
|
8903
|
-
const [rightPage, setRightPage] = (0,
|
|
8904
|
-
const [isLoading, setIsLoading] = (0,
|
|
9034
|
+
const [leftPage, setLeftPage] = (0, import_react39.useState)(null);
|
|
9035
|
+
const [rightPage, setRightPage] = (0, import_react39.useState)(null);
|
|
9036
|
+
const [isLoading, setIsLoading] = (0, import_react39.useState)(false);
|
|
8905
9037
|
const { selection, clearSelection, copySelection } = useTextSelection();
|
|
8906
9038
|
const {
|
|
8907
9039
|
createHighlightFromSelection,
|
|
@@ -8911,7 +9043,7 @@ var init_DualPageContainer = __esm({
|
|
|
8911
9043
|
selectHighlight,
|
|
8912
9044
|
activeColor
|
|
8913
9045
|
} = useHighlights();
|
|
8914
|
-
const getSpreadPages = (0,
|
|
9046
|
+
const getSpreadPages = (0, import_react39.useCallback)(
|
|
8915
9047
|
(page) => {
|
|
8916
9048
|
if (showCover && page === 1) {
|
|
8917
9049
|
return { left: null, right: 1 };
|
|
@@ -8955,14 +9087,14 @@ var init_DualPageContainer = __esm({
|
|
|
8955
9087
|
},
|
|
8956
9088
|
[showCover, bookSpread, numPages]
|
|
8957
9089
|
);
|
|
8958
|
-
(0,
|
|
9090
|
+
(0, import_react39.useEffect)(() => {
|
|
8959
9091
|
if (document2 !== documentRef.current) {
|
|
8960
9092
|
documentRef.current = document2;
|
|
8961
9093
|
setLeftPage(null);
|
|
8962
9094
|
setRightPage(null);
|
|
8963
9095
|
}
|
|
8964
9096
|
}, [document2]);
|
|
8965
|
-
(0,
|
|
9097
|
+
(0, import_react39.useEffect)(() => {
|
|
8966
9098
|
if (!document2) {
|
|
8967
9099
|
setLeftPage(null);
|
|
8968
9100
|
setRightPage(null);
|
|
@@ -8991,7 +9123,11 @@ var init_DualPageContainer = __esm({
|
|
|
8991
9123
|
}
|
|
8992
9124
|
} catch (error) {
|
|
8993
9125
|
if (!cancelled) {
|
|
8994
|
-
|
|
9126
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
9127
|
+
const isDocumentDestroyed = errorMessage.includes("destroyed") || errorMessage.includes("sendWithStream") || errorMessage.includes("sendWithPromise") || errorMessage.includes("Cannot read properties of null");
|
|
9128
|
+
if (!isDocumentDestroyed) {
|
|
9129
|
+
console.error("Error loading pages:", error);
|
|
9130
|
+
}
|
|
8995
9131
|
}
|
|
8996
9132
|
} finally {
|
|
8997
9133
|
if (!cancelled) {
|
|
@@ -9004,7 +9140,7 @@ var init_DualPageContainer = __esm({
|
|
|
9004
9140
|
cancelled = true;
|
|
9005
9141
|
};
|
|
9006
9142
|
}, [document2, currentPage, getSpreadPages, scrollToPageRequest, viewerStore]);
|
|
9007
|
-
const goToPreviousSpread = (0,
|
|
9143
|
+
const goToPreviousSpread = (0, import_react39.useCallback)(() => {
|
|
9008
9144
|
const spread2 = getSpreadPages(currentPage);
|
|
9009
9145
|
const leftmostPage = spread2.left || spread2.right || currentPage;
|
|
9010
9146
|
if (showCover && leftmostPage === 2) {
|
|
@@ -9016,21 +9152,21 @@ var init_DualPageContainer = __esm({
|
|
|
9016
9152
|
goToPage(newPage);
|
|
9017
9153
|
}
|
|
9018
9154
|
}, [currentPage, showCover, getSpreadPages, goToPage]);
|
|
9019
|
-
const goToNextSpread = (0,
|
|
9155
|
+
const goToNextSpread = (0, import_react39.useCallback)(() => {
|
|
9020
9156
|
const spread2 = getSpreadPages(currentPage);
|
|
9021
9157
|
const rightmostPage = spread2.right || spread2.left || currentPage;
|
|
9022
9158
|
if (rightmostPage < numPages) {
|
|
9023
9159
|
goToPage(Math.min(numPages, rightmostPage + 1));
|
|
9024
9160
|
}
|
|
9025
9161
|
}, [currentPage, numPages, getSpreadPages, goToPage]);
|
|
9026
|
-
const handlePinchZoom = (0,
|
|
9162
|
+
const handlePinchZoom = (0, import_react39.useCallback)(
|
|
9027
9163
|
(pinchScale) => {
|
|
9028
9164
|
const newScale = Math.max(0.25, Math.min(4, baseScaleRef.current * pinchScale));
|
|
9029
9165
|
setScale(newScale);
|
|
9030
9166
|
},
|
|
9031
9167
|
[setScale]
|
|
9032
9168
|
);
|
|
9033
|
-
(0,
|
|
9169
|
+
(0, import_react39.useEffect)(() => {
|
|
9034
9170
|
baseScaleRef.current = scale;
|
|
9035
9171
|
}, [scale]);
|
|
9036
9172
|
const { ref: touchRef } = useTouchGestures({
|
|
@@ -9039,20 +9175,20 @@ var init_DualPageContainer = __esm({
|
|
|
9039
9175
|
onSwipeRight: goToPreviousSpread,
|
|
9040
9176
|
enabled: enableTouchGestures && isTouchDevice
|
|
9041
9177
|
});
|
|
9042
|
-
const setContainerRef = (0,
|
|
9178
|
+
const setContainerRef = (0, import_react39.useCallback)(
|
|
9043
9179
|
(element) => {
|
|
9044
9180
|
containerRef.current = element;
|
|
9045
9181
|
touchRef(element);
|
|
9046
9182
|
},
|
|
9047
9183
|
[touchRef]
|
|
9048
9184
|
);
|
|
9049
|
-
const getPageElement = (0,
|
|
9185
|
+
const getPageElement = (0, import_react39.useCallback)(
|
|
9050
9186
|
(pageNumber) => {
|
|
9051
9187
|
return containerRef.current?.querySelector(`[data-page-number="${pageNumber}"]`);
|
|
9052
9188
|
},
|
|
9053
9189
|
[]
|
|
9054
9190
|
);
|
|
9055
|
-
const handleCreateHighlight = (0,
|
|
9191
|
+
const handleCreateHighlight = (0, import_react39.useCallback)(
|
|
9056
9192
|
(color) => {
|
|
9057
9193
|
if (!selection) return;
|
|
9058
9194
|
const pageElement = getPageElement(selection.pageNumber);
|
|
@@ -9062,13 +9198,13 @@ var init_DualPageContainer = __esm({
|
|
|
9062
9198
|
},
|
|
9063
9199
|
[selection, getPageElement, createHighlightFromSelection, scale, clearSelection]
|
|
9064
9200
|
);
|
|
9065
|
-
const handleColorChange = (0,
|
|
9201
|
+
const handleColorChange = (0, import_react39.useCallback)(
|
|
9066
9202
|
(id, color) => {
|
|
9067
9203
|
updateHighlight(id, { color });
|
|
9068
9204
|
},
|
|
9069
9205
|
[updateHighlight]
|
|
9070
9206
|
);
|
|
9071
|
-
const handleCommentChange = (0,
|
|
9207
|
+
const handleCommentChange = (0, import_react39.useCallback)(
|
|
9072
9208
|
(id, comment) => {
|
|
9073
9209
|
updateHighlight(id, { comment: comment || void 0 });
|
|
9074
9210
|
},
|
|
@@ -9081,23 +9217,20 @@ var init_DualPageContainer = __esm({
|
|
|
9081
9217
|
};
|
|
9082
9218
|
const spread = getSpreadPages(currentPage);
|
|
9083
9219
|
if (!document2) {
|
|
9084
|
-
|
|
9085
|
-
return null;
|
|
9086
|
-
}
|
|
9087
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9088
9221
|
"div",
|
|
9089
9222
|
{
|
|
9090
9223
|
className: cn(
|
|
9091
9224
|
"dual-page-container",
|
|
9092
|
-
"flex-1
|
|
9225
|
+
"flex-1",
|
|
9093
9226
|
themeStyles[theme],
|
|
9094
9227
|
className
|
|
9095
9228
|
),
|
|
9096
|
-
children: /* @__PURE__ */ (0,
|
|
9229
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(PDFLoadingScreen, { phase: isDocumentLoading ? "fetching" : "initializing" })
|
|
9097
9230
|
}
|
|
9098
9231
|
);
|
|
9099
9232
|
}
|
|
9100
|
-
return /* @__PURE__ */ (0,
|
|
9233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
9101
9234
|
"div",
|
|
9102
9235
|
{
|
|
9103
9236
|
ref: setContainerRef,
|
|
@@ -9110,13 +9243,13 @@ var init_DualPageContainer = __esm({
|
|
|
9110
9243
|
className
|
|
9111
9244
|
),
|
|
9112
9245
|
children: [
|
|
9113
|
-
/* @__PURE__ */ (0,
|
|
9246
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
9114
9247
|
"div",
|
|
9115
9248
|
{
|
|
9116
9249
|
className: "flex items-center",
|
|
9117
9250
|
style: { gap: pageGap },
|
|
9118
9251
|
children: [
|
|
9119
|
-
spread.left && /* @__PURE__ */ (0,
|
|
9252
|
+
spread.left && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9120
9253
|
PDFPage,
|
|
9121
9254
|
{
|
|
9122
9255
|
pageNumber: spread.left,
|
|
@@ -9125,14 +9258,14 @@ var init_DualPageContainer = __esm({
|
|
|
9125
9258
|
rotation
|
|
9126
9259
|
}
|
|
9127
9260
|
),
|
|
9128
|
-
spread.left && spread.right && /* @__PURE__ */ (0,
|
|
9261
|
+
spread.left && spread.right && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9129
9262
|
"div",
|
|
9130
9263
|
{
|
|
9131
9264
|
className: "w-px h-full bg-gray-300 dark:bg-gray-600 opacity-50",
|
|
9132
9265
|
style: { minHeight: "100%" }
|
|
9133
9266
|
}
|
|
9134
9267
|
),
|
|
9135
|
-
spread.right && /* @__PURE__ */ (0,
|
|
9268
|
+
spread.right && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9136
9269
|
PDFPage,
|
|
9137
9270
|
{
|
|
9138
9271
|
pageNumber: spread.right,
|
|
@@ -9141,7 +9274,7 @@ var init_DualPageContainer = __esm({
|
|
|
9141
9274
|
rotation
|
|
9142
9275
|
}
|
|
9143
9276
|
),
|
|
9144
|
-
(!spread.left || !spread.right) && /* @__PURE__ */ (0,
|
|
9277
|
+
(!spread.left || !spread.right) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9145
9278
|
"div",
|
|
9146
9279
|
{
|
|
9147
9280
|
className: "flex items-center justify-center",
|
|
@@ -9154,7 +9287,7 @@ var init_DualPageContainer = __esm({
|
|
|
9154
9287
|
]
|
|
9155
9288
|
}
|
|
9156
9289
|
),
|
|
9157
|
-
/* @__PURE__ */ (0,
|
|
9290
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9158
9291
|
SelectionToolbar,
|
|
9159
9292
|
{
|
|
9160
9293
|
selection,
|
|
@@ -9163,7 +9296,7 @@ var init_DualPageContainer = __esm({
|
|
|
9163
9296
|
activeColor
|
|
9164
9297
|
}
|
|
9165
9298
|
),
|
|
9166
|
-
/* @__PURE__ */ (0,
|
|
9299
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9167
9300
|
HighlightPopover,
|
|
9168
9301
|
{
|
|
9169
9302
|
highlight: selectedHighlight,
|
|
@@ -9175,7 +9308,7 @@ var init_DualPageContainer = __esm({
|
|
|
9175
9308
|
onClose: () => selectHighlight(null)
|
|
9176
9309
|
}
|
|
9177
9310
|
),
|
|
9178
|
-
isLoading && /* @__PURE__ */ (0,
|
|
9311
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "fixed bottom-4 right-4 px-3 py-2 bg-black/75 text-white text-sm rounded-lg", children: "Loading..." })
|
|
9179
9312
|
]
|
|
9180
9313
|
}
|
|
9181
9314
|
);
|
|
@@ -9184,15 +9317,15 @@ var init_DualPageContainer = __esm({
|
|
|
9184
9317
|
});
|
|
9185
9318
|
|
|
9186
9319
|
// src/components/FloatingZoomControls/FloatingZoomControls.tsx
|
|
9187
|
-
var
|
|
9320
|
+
var import_react40, import_jsx_runtime26, FloatingZoomControls;
|
|
9188
9321
|
var init_FloatingZoomControls = __esm({
|
|
9189
9322
|
"src/components/FloatingZoomControls/FloatingZoomControls.tsx"() {
|
|
9190
9323
|
"use strict";
|
|
9191
|
-
|
|
9324
|
+
import_react40 = require("react");
|
|
9192
9325
|
init_hooks();
|
|
9193
9326
|
init_utils();
|
|
9194
|
-
|
|
9195
|
-
FloatingZoomControls = (0,
|
|
9327
|
+
import_jsx_runtime26 = require("react/jsx-runtime");
|
|
9328
|
+
FloatingZoomControls = (0, import_react40.memo)(function FloatingZoomControls2({
|
|
9196
9329
|
position = "bottom-right",
|
|
9197
9330
|
className,
|
|
9198
9331
|
showFitToWidth = true,
|
|
@@ -9202,20 +9335,20 @@ var init_FloatingZoomControls = __esm({
|
|
|
9202
9335
|
const { viewerStore } = usePDFViewerStores();
|
|
9203
9336
|
const scale = useViewerStore((s) => s.scale);
|
|
9204
9337
|
const document2 = useViewerStore((s) => s.document);
|
|
9205
|
-
const handleZoomIn = (0,
|
|
9338
|
+
const handleZoomIn = (0, import_react40.useCallback)(() => {
|
|
9206
9339
|
const currentScale = viewerStore.getState().scale;
|
|
9207
9340
|
const newScale = Math.min(4, currentScale + 0.05);
|
|
9208
9341
|
viewerStore.getState().setScale(newScale);
|
|
9209
9342
|
}, [viewerStore]);
|
|
9210
|
-
const handleZoomOut = (0,
|
|
9343
|
+
const handleZoomOut = (0, import_react40.useCallback)(() => {
|
|
9211
9344
|
const currentScale = viewerStore.getState().scale;
|
|
9212
9345
|
const newScale = Math.max(0.1, currentScale - 0.05);
|
|
9213
9346
|
viewerStore.getState().setScale(newScale);
|
|
9214
9347
|
}, [viewerStore]);
|
|
9215
|
-
const handleFitToWidth = (0,
|
|
9348
|
+
const handleFitToWidth = (0, import_react40.useCallback)(() => {
|
|
9216
9349
|
viewerStore.getState().setScale(1);
|
|
9217
9350
|
}, [viewerStore]);
|
|
9218
|
-
const handleFitToPage = (0,
|
|
9351
|
+
const handleFitToPage = (0, import_react40.useCallback)(() => {
|
|
9219
9352
|
viewerStore.getState().setScale(0.75);
|
|
9220
9353
|
}, [viewerStore]);
|
|
9221
9354
|
if (!document2) return null;
|
|
@@ -9226,7 +9359,7 @@ var init_FloatingZoomControls = __esm({
|
|
|
9226
9359
|
"top-left": "top-4 left-4"
|
|
9227
9360
|
};
|
|
9228
9361
|
const zoomPercentage = Math.round(scale * 100);
|
|
9229
|
-
return /* @__PURE__ */ (0,
|
|
9362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
9230
9363
|
"div",
|
|
9231
9364
|
{
|
|
9232
9365
|
className: cn(
|
|
@@ -9238,7 +9371,7 @@ var init_FloatingZoomControls = __esm({
|
|
|
9238
9371
|
className
|
|
9239
9372
|
),
|
|
9240
9373
|
children: [
|
|
9241
|
-
/* @__PURE__ */ (0,
|
|
9374
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9242
9375
|
"button",
|
|
9243
9376
|
{
|
|
9244
9377
|
onClick: handleZoomOut,
|
|
@@ -9252,14 +9385,14 @@ var init_FloatingZoomControls = __esm({
|
|
|
9252
9385
|
disabled: scale <= 0.25,
|
|
9253
9386
|
title: "Zoom Out",
|
|
9254
9387
|
"aria-label": "Zoom Out",
|
|
9255
|
-
children: /* @__PURE__ */ (0,
|
|
9388
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20 12H4" }) })
|
|
9256
9389
|
}
|
|
9257
9390
|
),
|
|
9258
|
-
showZoomLevel && /* @__PURE__ */ (0,
|
|
9391
|
+
showZoomLevel && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "min-w-[48px] text-center text-sm font-medium text-gray-700 dark:text-gray-300", children: [
|
|
9259
9392
|
zoomPercentage,
|
|
9260
9393
|
"%"
|
|
9261
9394
|
] }),
|
|
9262
|
-
/* @__PURE__ */ (0,
|
|
9395
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9263
9396
|
"button",
|
|
9264
9397
|
{
|
|
9265
9398
|
onClick: handleZoomIn,
|
|
@@ -9273,11 +9406,11 @@ var init_FloatingZoomControls = __esm({
|
|
|
9273
9406
|
disabled: scale >= 4,
|
|
9274
9407
|
title: "Zoom In",
|
|
9275
9408
|
"aria-label": "Zoom In",
|
|
9276
|
-
children: /* @__PURE__ */ (0,
|
|
9409
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 4v16m8-8H4" }) })
|
|
9277
9410
|
}
|
|
9278
9411
|
),
|
|
9279
|
-
(showFitToWidth || showFitToPage) && /* @__PURE__ */ (0,
|
|
9280
|
-
showFitToWidth && /* @__PURE__ */ (0,
|
|
9412
|
+
(showFitToWidth || showFitToPage) && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "w-px h-6 bg-gray-200 dark:bg-gray-700 mx-1" }),
|
|
9413
|
+
showFitToWidth && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9281
9414
|
"button",
|
|
9282
9415
|
{
|
|
9283
9416
|
onClick: handleFitToWidth,
|
|
@@ -9289,10 +9422,10 @@ var init_FloatingZoomControls = __esm({
|
|
|
9289
9422
|
),
|
|
9290
9423
|
title: "Fit to Width",
|
|
9291
9424
|
"aria-label": "Fit to Width",
|
|
9292
|
-
children: /* @__PURE__ */ (0,
|
|
9425
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" }) })
|
|
9293
9426
|
}
|
|
9294
9427
|
),
|
|
9295
|
-
showFitToPage && /* @__PURE__ */ (0,
|
|
9428
|
+
showFitToPage && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9296
9429
|
"button",
|
|
9297
9430
|
{
|
|
9298
9431
|
onClick: handleFitToPage,
|
|
@@ -9304,7 +9437,7 @@ var init_FloatingZoomControls = __esm({
|
|
|
9304
9437
|
),
|
|
9305
9438
|
title: "Fit to Page",
|
|
9306
9439
|
"aria-label": "Fit to Page",
|
|
9307
|
-
children: /* @__PURE__ */ (0,
|
|
9440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) })
|
|
9308
9441
|
}
|
|
9309
9442
|
)
|
|
9310
9443
|
]
|
|
@@ -9322,138 +9455,6 @@ var init_FloatingZoomControls2 = __esm({
|
|
|
9322
9455
|
}
|
|
9323
9456
|
});
|
|
9324
9457
|
|
|
9325
|
-
// src/components/PDFLoadingScreen/PDFLoadingScreen.tsx
|
|
9326
|
-
function formatBytes(bytes) {
|
|
9327
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
9328
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
9329
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
9330
|
-
}
|
|
9331
|
-
var import_react40, import_jsx_runtime26, phaseMessages, PDFLoadingScreen;
|
|
9332
|
-
var init_PDFLoadingScreen = __esm({
|
|
9333
|
-
"src/components/PDFLoadingScreen/PDFLoadingScreen.tsx"() {
|
|
9334
|
-
"use strict";
|
|
9335
|
-
import_react40 = require("react");
|
|
9336
|
-
init_utils();
|
|
9337
|
-
import_jsx_runtime26 = require("react/jsx-runtime");
|
|
9338
|
-
phaseMessages = {
|
|
9339
|
-
initializing: "Initializing...",
|
|
9340
|
-
fetching: "Loading document...",
|
|
9341
|
-
parsing: "Processing pages...",
|
|
9342
|
-
rendering: "Preparing view..."
|
|
9343
|
-
};
|
|
9344
|
-
PDFLoadingScreen = (0, import_react40.memo)(function PDFLoadingScreen2({
|
|
9345
|
-
progress,
|
|
9346
|
-
bytesLoaded,
|
|
9347
|
-
totalBytes,
|
|
9348
|
-
phase = "fetching",
|
|
9349
|
-
documentName,
|
|
9350
|
-
className
|
|
9351
|
-
}) {
|
|
9352
|
-
const hasProgress = progress !== void 0 && progress >= 0;
|
|
9353
|
-
const hasBytes = bytesLoaded !== void 0 && totalBytes !== void 0 && totalBytes > 0;
|
|
9354
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
9355
|
-
"div",
|
|
9356
|
-
{
|
|
9357
|
-
className: cn(
|
|
9358
|
-
"pdf-loading-screen",
|
|
9359
|
-
"flex flex-col items-center justify-center",
|
|
9360
|
-
"w-full h-full min-h-[400px]",
|
|
9361
|
-
"bg-slate-50 dark:bg-slate-800",
|
|
9362
|
-
className
|
|
9363
|
-
),
|
|
9364
|
-
role: "status",
|
|
9365
|
-
"aria-live": "polite",
|
|
9366
|
-
"aria-label": phaseMessages[phase],
|
|
9367
|
-
children: [
|
|
9368
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "pdf-loading-skeleton", children: [
|
|
9369
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pdf-loading-icon", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
9370
|
-
"svg",
|
|
9371
|
-
{
|
|
9372
|
-
width: "48",
|
|
9373
|
-
height: "56",
|
|
9374
|
-
viewBox: "0 0 48 56",
|
|
9375
|
-
fill: "none",
|
|
9376
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
9377
|
-
className: "pdf-document-icon",
|
|
9378
|
-
children: [
|
|
9379
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9380
|
-
"path",
|
|
9381
|
-
{
|
|
9382
|
-
d: "M4 4C4 1.79086 5.79086 0 8 0H30L44 14V52C44 54.2091 42.2091 56 40 56H8C5.79086 56 4 54.2091 4 52V4Z",
|
|
9383
|
-
className: "fill-white dark:fill-slate-700"
|
|
9384
|
-
}
|
|
9385
|
-
),
|
|
9386
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9387
|
-
"path",
|
|
9388
|
-
{
|
|
9389
|
-
d: "M30 0L44 14H34C31.7909 14 30 12.2091 30 10V0Z",
|
|
9390
|
-
className: "fill-slate-200 dark:fill-slate-600"
|
|
9391
|
-
}
|
|
9392
|
-
),
|
|
9393
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("rect", { x: "10", y: "22", width: "24", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
9394
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("rect", { x: "10", y: "28", width: "20", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
9395
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("rect", { x: "10", y: "34", width: "22", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
9396
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("rect", { x: "10", y: "40", width: "16", height: "3", rx: "1.5", className: "fill-slate-200 dark:fill-slate-600" }),
|
|
9397
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9398
|
-
"path",
|
|
9399
|
-
{
|
|
9400
|
-
d: "M4 4C4 1.79086 5.79086 0 8 0H30L44 14V52C44 54.2091 42.2091 56 40 56H8C5.79086 56 4 54.2091 4 52V4Z",
|
|
9401
|
-
className: "stroke-slate-300 dark:stroke-slate-500",
|
|
9402
|
-
strokeWidth: "1",
|
|
9403
|
-
fill: "none"
|
|
9404
|
-
}
|
|
9405
|
-
)
|
|
9406
|
-
]
|
|
9407
|
-
}
|
|
9408
|
-
) }),
|
|
9409
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "pdf-skeleton-lines", children: [
|
|
9410
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pdf-skeleton-line pdf-skeleton-line-1" }),
|
|
9411
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pdf-skeleton-line pdf-skeleton-line-2" }),
|
|
9412
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pdf-skeleton-line pdf-skeleton-line-3" })
|
|
9413
|
-
] })
|
|
9414
|
-
] }),
|
|
9415
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "pdf-loading-info", children: [
|
|
9416
|
-
documentName && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "pdf-loading-document-name", children: documentName }),
|
|
9417
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "pdf-loading-message", children: phaseMessages[phase] }),
|
|
9418
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "pdf-loading-progress-container", children: [
|
|
9419
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "pdf-loading-progress-track", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9420
|
-
"div",
|
|
9421
|
-
{
|
|
9422
|
-
className: cn(
|
|
9423
|
-
"pdf-loading-progress-fill",
|
|
9424
|
-
!hasProgress && "pdf-loading-progress-indeterminate"
|
|
9425
|
-
),
|
|
9426
|
-
style: hasProgress ? { width: `${Math.min(100, progress)}%` } : void 0
|
|
9427
|
-
}
|
|
9428
|
-
) }),
|
|
9429
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "pdf-loading-progress-details", children: [
|
|
9430
|
-
hasProgress && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "pdf-loading-progress-percent", children: [
|
|
9431
|
-
Math.round(progress),
|
|
9432
|
-
"%"
|
|
9433
|
-
] }),
|
|
9434
|
-
hasBytes && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { className: "pdf-loading-progress-bytes", children: [
|
|
9435
|
-
formatBytes(bytesLoaded),
|
|
9436
|
-
" / ",
|
|
9437
|
-
formatBytes(totalBytes)
|
|
9438
|
-
] })
|
|
9439
|
-
] })
|
|
9440
|
-
] })
|
|
9441
|
-
] })
|
|
9442
|
-
]
|
|
9443
|
-
}
|
|
9444
|
-
);
|
|
9445
|
-
});
|
|
9446
|
-
}
|
|
9447
|
-
});
|
|
9448
|
-
|
|
9449
|
-
// src/components/PDFLoadingScreen/index.ts
|
|
9450
|
-
var init_PDFLoadingScreen2 = __esm({
|
|
9451
|
-
"src/components/PDFLoadingScreen/index.ts"() {
|
|
9452
|
-
"use strict";
|
|
9453
|
-
init_PDFLoadingScreen();
|
|
9454
|
-
}
|
|
9455
|
-
});
|
|
9456
|
-
|
|
9457
9458
|
// src/components/PDFViewer/PDFViewerClient.tsx
|
|
9458
9459
|
var PDFViewerClient_exports = {};
|
|
9459
9460
|
__export(PDFViewerClient_exports, {
|
|
@@ -11762,7 +11763,11 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
11762
11763
|
});
|
|
11763
11764
|
}
|
|
11764
11765
|
} catch (error) {
|
|
11765
|
-
|
|
11766
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
11767
|
+
const isDocumentDestroyed = errorMessage.includes("destroyed") || errorMessage.includes("sendWithStream") || errorMessage.includes("sendWithPromise") || errorMessage.includes("Cannot read properties of null");
|
|
11768
|
+
if (!isDocumentDestroyed) {
|
|
11769
|
+
console.error(`Failed to render thumbnail for page ${pageNum}:`, error);
|
|
11770
|
+
}
|
|
11766
11771
|
} finally {
|
|
11767
11772
|
renderQueueRef.current.delete(pageNum);
|
|
11768
11773
|
}
|