pdfjs-reader-core 0.2.6 → 0.2.8

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 CHANGED
@@ -4777,7 +4777,7 @@ var init_ThumbnailPanel = __esm({
4777
4777
  className,
4778
4778
  thumbnailScale = 0.2
4779
4779
  }) {
4780
- const { document: document2, currentPage, numPages, goToPage } = usePDFViewer();
4780
+ const { document: document2, currentPage, numPages, goToPage, isLoading } = usePDFViewer();
4781
4781
  const containerRef = (0, import_react18.useRef)(null);
4782
4782
  (0, import_react18.useEffect)(() => {
4783
4783
  const container = containerRef.current;
@@ -4794,6 +4794,9 @@ var init_ThumbnailPanel = __esm({
4794
4794
  [goToPage]
4795
4795
  );
4796
4796
  if (!document2) {
4797
+ if (isLoading) {
4798
+ return null;
4799
+ }
4797
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" }) });
4798
4801
  }
4799
4802
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -5125,7 +5128,7 @@ var init_OutlinePanel = __esm({
5125
5128
  OutlinePanel = (0, import_react20.memo)(function OutlinePanel2({
5126
5129
  className
5127
5130
  }) {
5128
- const { document: document2, goToPage } = usePDFViewer();
5131
+ const { document: document2, goToPage, isLoading: isDocumentLoading } = usePDFViewer();
5129
5132
  const [outline, setOutline] = (0, import_react20.useState)(null);
5130
5133
  const [isLoading, setIsLoading] = (0, import_react20.useState)(false);
5131
5134
  const [error, setError] = (0, import_react20.useState)(null);
@@ -5204,6 +5207,9 @@ var init_OutlinePanel = __esm({
5204
5207
  [goToPage]
5205
5208
  );
5206
5209
  if (!document2) {
5210
+ if (isDocumentLoading) {
5211
+ return null;
5212
+ }
5207
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" }) });
5208
5214
  }
5209
5215
  if (isLoading) {
@@ -8243,6 +8249,7 @@ var init_DocumentContainer = __esm({
8243
8249
  scale,
8244
8250
  rotation,
8245
8251
  theme,
8252
+ isLoading,
8246
8253
  setScale,
8247
8254
  nextPage,
8248
8255
  previousPage
@@ -8382,6 +8389,9 @@ var init_DocumentContainer = __esm({
8382
8389
  sepia: "bg-amber-50"
8383
8390
  };
8384
8391
  if (!document2) {
8392
+ if (isLoading) {
8393
+ return null;
8394
+ }
8385
8395
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
8386
8396
  "div",
8387
8397
  {
@@ -8474,6 +8484,7 @@ var init_VirtualizedDocumentContainer = __esm({
8474
8484
  scale,
8475
8485
  rotation,
8476
8486
  theme,
8487
+ isLoading,
8477
8488
  setScale,
8478
8489
  goToPage,
8479
8490
  nextPage,
@@ -8729,6 +8740,9 @@ var init_VirtualizedDocumentContainer = __esm({
8729
8740
  sepia: "bg-amber-50"
8730
8741
  };
8731
8742
  if (!document2) {
8743
+ if (isLoading) {
8744
+ return null;
8745
+ }
8732
8746
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
8733
8747
  "div",
8734
8748
  {
@@ -8875,6 +8889,7 @@ var init_DualPageContainer = __esm({
8875
8889
  scale,
8876
8890
  rotation,
8877
8891
  theme,
8892
+ isLoading: isDocumentLoading,
8878
8893
  setScale,
8879
8894
  goToPage
8880
8895
  } = usePDFViewer();
@@ -9066,6 +9081,9 @@ var init_DualPageContainer = __esm({
9066
9081
  };
9067
9082
  const spread = getSpreadPages(currentPage);
9068
9083
  if (!document2) {
9084
+ if (isDocumentLoading) {
9085
+ return null;
9086
+ }
9069
9087
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
9070
9088
  "div",
9071
9089
  {
@@ -10000,12 +10018,13 @@ var init_PDFViewerClient = __esm({
10000
10018
  currentDoc.destroy();
10001
10019
  viewerStore.getState().setDocument(null);
10002
10020
  }
10021
+ viewerStore.getState().setLoading(true, { phase: "initializing" });
10022
+ viewerStore.getState().setError(null);
10023
+ setLoadState("loading");
10003
10024
  const loadDoc = async () => {
10004
10025
  if (!mountedRef.current) return;
10005
10026
  try {
10006
- viewerStore.getState().setLoading(true, { phase: "fetching" });
10007
- viewerStore.getState().setError(null);
10008
- setLoadState("loading");
10027
+ viewerStore.getState().setLoadingProgress({ phase: "fetching" });
10009
10028
  const { document: document2, numPages } = await loadDocument({
10010
10029
  src,
10011
10030
  workerSrc,