@arbidocs/react 0.5.86 → 0.5.88
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/README.md +2 -3
- package/dist/artifacts/index.cjs +46 -48
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.js +7 -9
- package/dist/artifacts/index.js.map +1 -1
- package/dist/calls/livekit/index.cjs +60 -62
- package/dist/calls/livekit/index.cjs.map +1 -1
- package/dist/calls/livekit/index.js +6 -8
- package/dist/calls/livekit/index.js.map +1 -1
- package/dist/{chunk-Z3LLUO32.cjs → chunk-5NOZDH3F.cjs} +12 -2
- package/dist/chunk-5NOZDH3F.cjs.map +1 -0
- package/dist/{chunk-WQY3RQ6G.js → chunk-73ENECAT.js} +5 -6
- package/dist/{chunk-LUDIYWT7.cjs.map → chunk-73ENECAT.js.map} +1 -1
- package/dist/{chunk-2Y2WOIHH.cjs → chunk-AOPGD23L.cjs} +60 -148
- package/dist/chunk-AOPGD23L.cjs.map +1 -0
- package/dist/{chunk-G4Z3IP4J.js → chunk-BF5KW5ZI.js} +3 -17
- package/dist/chunk-BF5KW5ZI.js.map +1 -0
- package/dist/{chunk-TK7ERJPE.js → chunk-BFNY3RZG.js} +22 -12
- package/dist/chunk-BFNY3RZG.js.map +1 -0
- package/dist/{chunk-U4PWVSCT.cjs → chunk-C4WODQGO.cjs} +24 -11
- package/dist/chunk-C4WODQGO.cjs.map +1 -0
- package/dist/{chunk-E7VD5WNY.cjs → chunk-DS7NTSKH.cjs} +41 -74
- package/dist/chunk-DS7NTSKH.cjs.map +1 -0
- package/dist/{chunk-JT7PN7JH.js → chunk-DU2P354H.js} +6 -37
- package/dist/chunk-DU2P354H.js.map +1 -0
- package/dist/{chunk-TAVS54EN.cjs → chunk-GKWMT64A.cjs} +6 -6
- package/dist/{chunk-TAVS54EN.cjs.map → chunk-GKWMT64A.cjs.map} +1 -1
- package/dist/{chunk-AXKHDLBB.cjs → chunk-HEVPIVF2.cjs} +15 -15
- package/dist/{chunk-AXKHDLBB.cjs.map → chunk-HEVPIVF2.cjs.map} +1 -1
- package/dist/{chunk-XPLD4LFC.js → chunk-KTXZ222T.js} +6 -91
- package/dist/chunk-KTXZ222T.js.map +1 -0
- package/dist/{chunk-PXWKJI4K.cjs → chunk-LBAG7KL7.cjs} +35 -261
- package/dist/chunk-LBAG7KL7.cjs.map +1 -0
- package/dist/{chunk-CSPAEVZS.js → chunk-MS43RNXM.js} +5 -5
- package/dist/{chunk-CSPAEVZS.js.map → chunk-MS43RNXM.js.map} +1 -1
- package/dist/{chunk-OC7F5SNA.cjs → chunk-MXP4O4DI.cjs} +5 -5
- package/dist/{chunk-OC7F5SNA.cjs.map → chunk-MXP4O4DI.cjs.map} +1 -1
- package/dist/{chunk-ZWFMFOGP.cjs → chunk-NDIKMOBJ.cjs} +4 -4
- package/dist/{chunk-ZWFMFOGP.cjs.map → chunk-NDIKMOBJ.cjs.map} +1 -1
- package/dist/{chunk-XAEVT7ZM.js → chunk-NNAJLY6B.js} +34 -257
- package/dist/chunk-NNAJLY6B.js.map +1 -0
- package/dist/{chunk-LUDIYWT7.cjs → chunk-QLRDHLWR.cjs} +72 -73
- package/dist/chunk-QLRDHLWR.cjs.map +1 -0
- package/dist/{chunk-DZUBZ45Y.cjs → chunk-RLSBRZ6Z.cjs} +2 -17
- package/dist/chunk-RLSBRZ6Z.cjs.map +1 -0
- package/dist/{chunk-VGAA7AFS.js → chunk-S3OGDLDC.js} +4 -13
- package/dist/chunk-S3OGDLDC.js.map +1 -0
- package/dist/{chunk-NNWMHMEC.js → chunk-UW2SGTI5.js} +3 -3
- package/dist/{chunk-NNWMHMEC.js.map → chunk-UW2SGTI5.js.map} +1 -1
- package/dist/{chunk-QRCMKEE6.js → chunk-VSCU7K4V.js} +11 -3
- package/dist/chunk-VSCU7K4V.js.map +1 -0
- package/dist/{chunk-C44GO33B.js → chunk-WL2Y2T47.js} +3 -3
- package/dist/{chunk-C44GO33B.js.map → chunk-WL2Y2T47.js.map} +1 -1
- package/dist/{chunk-47YVW3J4.js → chunk-YQBDEOVE.js} +4 -4
- package/dist/{chunk-47YVW3J4.js.map → chunk-YQBDEOVE.js.map} +1 -1
- package/dist/{chunk-Q6U7ALNV.cjs → chunk-ZHXYFJIA.cjs} +44 -54
- package/dist/chunk-ZHXYFJIA.cjs.map +1 -0
- package/dist/document-tools/core.cjs +100 -110
- package/dist/document-tools/core.d.cts +3 -78
- package/dist/document-tools/core.d.ts +3 -78
- package/dist/document-tools/core.js +5 -7
- package/dist/document-tools/index.cjs +102 -112
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.d.cts +2 -2
- package/dist/document-tools/index.d.ts +2 -2
- package/dist/document-tools/index.js +6 -8
- package/dist/document-tools/index.js.map +1 -1
- package/dist/index.cjs +1740 -2305
- package/dist/index.cjs.map +1 -1
- package/dist/{index.d-BDcwpFVa.d.cts → index.d-1_bJB-Yl.d.cts} +1 -58
- package/dist/{index.d-BDcwpFVa.d.ts → index.d-1_bJB-Yl.d.ts} +1 -58
- package/dist/{index.d-Deqz5-pF.d.ts → index.d-ChaR6kMc.d.cts} +1 -6
- package/dist/{index.d-Deqz5-pF.d.cts → index.d-ChaR6kMc.d.ts} +1 -6
- package/dist/index.d.cts +184 -1423
- package/dist/index.d.ts +184 -1423
- package/dist/index.js +281 -799
- package/dist/index.js.map +1 -1
- package/dist/{query-keys.d-Dm0NL9nr.d.cts → query-keys.d-D6SAUl7S.d.cts} +0 -9
- package/dist/{query-keys.d-Dm0NL9nr.d.ts → query-keys.d-D6SAUl7S.d.ts} +0 -9
- package/dist/shell/index.cjs +48 -53
- package/dist/shell/index.d.cts +1 -1
- package/dist/shell/index.d.ts +1 -1
- package/dist/shell/index.js +4 -5
- package/dist/ui/index.cjs +156 -169
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -4
- package/dist/viewers/index.cjs +0 -120
- package/dist/viewers/index.cjs.map +1 -1
- package/dist/viewers/index.d.cts +3 -40
- package/dist/viewers/index.d.ts +3 -40
- package/dist/viewers/index.js +1 -120
- package/dist/viewers/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-2Y2WOIHH.cjs.map +0 -1
- package/dist/chunk-CPZ36AQS.js +0 -11
- package/dist/chunk-CPZ36AQS.js.map +0 -1
- package/dist/chunk-DZUBZ45Y.cjs.map +0 -1
- package/dist/chunk-E7VD5WNY.cjs.map +0 -1
- package/dist/chunk-G4Z3IP4J.js.map +0 -1
- package/dist/chunk-JT7PN7JH.js.map +0 -1
- package/dist/chunk-PXWKJI4K.cjs.map +0 -1
- package/dist/chunk-Q6U7ALNV.cjs.map +0 -1
- package/dist/chunk-QRCMKEE6.js.map +0 -1
- package/dist/chunk-RCKA7BEF.cjs +0 -14
- package/dist/chunk-RCKA7BEF.cjs.map +0 -1
- package/dist/chunk-TK7ERJPE.js.map +0 -1
- package/dist/chunk-U4PWVSCT.cjs.map +0 -1
- package/dist/chunk-VGAA7AFS.js.map +0 -1
- package/dist/chunk-VGMMK5OM.cjs +0 -26
- package/dist/chunk-VGMMK5OM.cjs.map +0 -1
- package/dist/chunk-VGO77X5U.js +0 -22
- package/dist/chunk-VGO77X5U.js.map +0 -1
- package/dist/chunk-WQY3RQ6G.js.map +0 -1
- package/dist/chunk-XAEVT7ZM.js.map +0 -1
- package/dist/chunk-XPLD4LFC.js.map +0 -1
- package/dist/chunk-Z3LLUO32.cjs.map +0 -1
package/dist/viewers/index.d.ts
CHANGED
|
@@ -1,43 +1,6 @@
|
|
|
1
|
+
export { P as PdfViewer, a as PdfViewerAssets, b as PdfViewerProps } from '../PdfViewer.d-bQH9yxFg.js';
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { components } from '@arbidocs/client';
|
|
4
|
-
import { a as PdfViewerAssets } from '../PdfViewer.d-bQH9yxFg.js';
|
|
5
|
-
export { P as PdfViewer, b as PdfViewerProps } from '../PdfViewer.d-bQH9yxFg.js';
|
|
6
|
-
|
|
7
|
-
type DocResponse = components['schemas']['DocResponse'];
|
|
8
|
-
/** Which native renderer a file needs; `none` when there is no native view. */
|
|
9
|
-
type NativeViewerKind = 'pdf' | 'docx' | 'xlsx' | 'image' | 'audio' | 'video' | 'none';
|
|
10
|
-
/**
|
|
11
|
-
* Which viewer a document needs. Extension first (it is what the user sees and
|
|
12
|
-
* what ARBI preserves), falling back to the sniffed `file_type` — ARBI
|
|
13
|
-
* identifies by digital signature, so a mislabelled file still renders.
|
|
14
|
-
*/
|
|
15
|
-
declare function nativeViewerKind(doc: Pick<DocResponse, 'file_name' | 'file_type'> | undefined): NativeViewerKind;
|
|
16
|
-
interface DocumentViewerProps {
|
|
17
|
-
/** The document to render. */
|
|
18
|
-
doc: Pick<DocResponse, 'external_id' | 'file_name' | 'file_type'> | undefined;
|
|
19
|
-
/** Where the app serves the pdf.js worker, cmaps and standard fonts from. */
|
|
20
|
-
pdfAssets?: PdfViewerAssets;
|
|
21
|
-
/** Reported as the user scrolls a paged document. */
|
|
22
|
-
onPageChange?: (page: number) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Page to show. Paired with `scrollTrigger` this drives a page-number control:
|
|
25
|
-
* a viewer without one is an endless scroll with no way to say "go to 14".
|
|
26
|
-
*/
|
|
27
|
-
currentPage?: number;
|
|
28
|
-
/** Increment to scroll to `currentPage` — lets the same value be re-applied. */
|
|
29
|
-
scrollTrigger?: number;
|
|
30
|
-
/** Page count, once the document has loaded. Needed to render "of N". */
|
|
31
|
-
onLoadSuccess?: (numPages: number) => void;
|
|
32
|
-
/** Rendered when the file type has no native viewer. */
|
|
33
|
-
fallback?: ReactNode;
|
|
34
|
-
/** Rendered while the original is downloading. */
|
|
35
|
-
loading?: ReactNode;
|
|
36
|
-
/** Rendered when the download or decode fails. Receives the message. */
|
|
37
|
-
errorRender?: (message: string) => ReactNode;
|
|
38
|
-
className?: string;
|
|
39
|
-
}
|
|
40
|
-
declare function DocumentViewer({ doc, pdfAssets, onPageChange, currentPage, scrollTrigger, onLoadSuccess, fallback, loading, errorRender, className, }: DocumentViewerProps): React.JSX.Element | null;
|
|
3
|
+
import { RefObject } from 'react';
|
|
41
4
|
|
|
42
5
|
/**
|
|
43
6
|
* Shims for the newer JS built-ins pdf.js 6 calls on the main thread, which browsers still in use
|
|
@@ -294,4 +257,4 @@ interface ChunkRunInfo {
|
|
|
294
257
|
}
|
|
295
258
|
declare function computeSelectionRuns(pages: RunPage[], selectedChunks: Set<string>): Map<string, ChunkRunInfo>;
|
|
296
259
|
|
|
297
|
-
export { AudioViewer, type AudioViewerProps, type ChunkRunInfo,
|
|
260
|
+
export { AudioViewer, type AudioViewerProps, type ChunkRunInfo, DocxViewer, type DocxViewerProps, INITIAL_LAZY_LOAD_BUFFER, ImageViewer, type ImageViewerProps, LAZY_LOAD_BUFFER_AFTER, LAZY_LOAD_BUFFER_BEFORE, MAX_ZOOM, MIN_ZOOM, PAGE_SELECTOR, type ProcessedChunk, type ProcessedPage, type RawChunk, type RunChunk, type RunPage, type UseProcessedChunksResult, VideoViewer, type VideoViewerProps, XlsxViewer, type XlsxViewerProps, anchorDelta, anchoredScroll, clampZoom, computeSelectionRuns, cycleZoom, doubleTapZoom, installPdfjsPolyfills, pinchZoom, renderDpr, usePageIntersectionObserver, usePinchZoom, useProcessedChunks, useScrollAnchor, zoomLabel };
|
package/dist/viewers/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { installPdfjsPolyfills } from '../chunk-PTOP7OHG.js';
|
|
2
2
|
export { installPdfjsPolyfills } from '../chunk-PTOP7OHG.js';
|
|
3
|
-
import { VideoViewer, AudioViewer, ImageViewer } from '../chunk-HDCRPPBW.js';
|
|
4
3
|
export { AudioViewer, ImageViewer, VideoViewer } from '../chunk-HDCRPPBW.js';
|
|
5
|
-
import { useArbi } from '../chunk-VGO77X5U.js';
|
|
6
|
-
import '../chunk-CPZ36AQS.js';
|
|
7
4
|
import { useEffect, useRef, useCallback, useLayoutEffect, useState, useMemo } from 'react';
|
|
8
5
|
import { Document, Page, pdfjs } from 'react-pdf';
|
|
9
6
|
import 'react-pdf/dist/Page/AnnotationLayer.css';
|
|
@@ -813,122 +810,6 @@ function XlsxViewer({ blob }) {
|
|
|
813
810
|
}
|
|
814
811
|
);
|
|
815
812
|
}
|
|
816
|
-
var BY_EXTENSION = {
|
|
817
|
-
pdf: "pdf",
|
|
818
|
-
doc: "docx",
|
|
819
|
-
docx: "docx",
|
|
820
|
-
xls: "xlsx",
|
|
821
|
-
xlsx: "xlsx",
|
|
822
|
-
csv: "xlsx",
|
|
823
|
-
png: "image",
|
|
824
|
-
jpg: "image",
|
|
825
|
-
jpeg: "image",
|
|
826
|
-
gif: "image",
|
|
827
|
-
webp: "image",
|
|
828
|
-
bmp: "image",
|
|
829
|
-
tif: "image",
|
|
830
|
-
tiff: "image",
|
|
831
|
-
mp3: "audio",
|
|
832
|
-
wav: "audio",
|
|
833
|
-
m4a: "audio",
|
|
834
|
-
ogg: "audio",
|
|
835
|
-
mp4: "video",
|
|
836
|
-
mov: "video",
|
|
837
|
-
webm: "video",
|
|
838
|
-
avi: "video"
|
|
839
|
-
};
|
|
840
|
-
function nativeViewerKind(doc) {
|
|
841
|
-
const name = (doc?.file_name ?? "").toLowerCase();
|
|
842
|
-
const ext = name.includes(".") ? name.slice(name.lastIndexOf(".") + 1) : "";
|
|
843
|
-
if (BY_EXTENSION[ext]) return BY_EXTENSION[ext];
|
|
844
|
-
const type = (doc?.file_type ?? "").toLowerCase();
|
|
845
|
-
if (!type) return "none";
|
|
846
|
-
if (type.includes("pdf")) return "pdf";
|
|
847
|
-
if (type.includes("word") || type.includes("officedocument.wordprocessing")) return "docx";
|
|
848
|
-
if (type.includes("sheet") || type.includes("excel") || type.includes("csv")) return "xlsx";
|
|
849
|
-
if (type.startsWith("image/")) return "image";
|
|
850
|
-
if (type.startsWith("audio/")) return "audio";
|
|
851
|
-
if (type.startsWith("video/")) return "video";
|
|
852
|
-
return "none";
|
|
853
|
-
}
|
|
854
|
-
function DocumentViewer({
|
|
855
|
-
doc,
|
|
856
|
-
pdfAssets,
|
|
857
|
-
onPageChange,
|
|
858
|
-
currentPage,
|
|
859
|
-
scrollTrigger,
|
|
860
|
-
onLoadSuccess,
|
|
861
|
-
fallback,
|
|
862
|
-
loading,
|
|
863
|
-
errorRender,
|
|
864
|
-
className
|
|
865
|
-
}) {
|
|
866
|
-
const arbi = useArbi();
|
|
867
|
-
const [blob, setBlob] = useState(null);
|
|
868
|
-
const [error, setError] = useState(null);
|
|
869
|
-
const kind = useMemo(() => nativeViewerKind(doc), [doc]);
|
|
870
|
-
const docId = doc?.external_id;
|
|
871
|
-
useEffect(() => {
|
|
872
|
-
if (!docId || kind === "none") {
|
|
873
|
-
setBlob(null);
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
let cancelled = false;
|
|
877
|
-
setBlob(null);
|
|
878
|
-
setError(null);
|
|
879
|
-
arbi.documents.download(docId).then((res) => res.blob()).then((b) => {
|
|
880
|
-
if (!cancelled) setBlob(b);
|
|
881
|
-
}).catch((err) => {
|
|
882
|
-
if (!cancelled) setError(err instanceof Error ? err.message : "Could not load the file");
|
|
883
|
-
});
|
|
884
|
-
return () => {
|
|
885
|
-
cancelled = true;
|
|
886
|
-
};
|
|
887
|
-
}, [arbi, docId, kind]);
|
|
888
|
-
if (!doc) return null;
|
|
889
|
-
if (kind === "none") {
|
|
890
|
-
return /* @__PURE__ */ jsx(Fragment, { children: fallback ?? /* @__PURE__ */ jsx("div", { className: "grid h-full place-items-center p-6 text-center text-sm text-muted-foreground", children: "No native view for this file type. The original is preserved and can be downloaded." }) });
|
|
891
|
-
}
|
|
892
|
-
if (error) {
|
|
893
|
-
return /* @__PURE__ */ jsx(Fragment, { children: errorRender?.(error) ?? /* @__PURE__ */ jsx("div", { className: "grid h-full place-items-center p-6 text-center", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
894
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-destructive", children: "Could not load the original" }),
|
|
895
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: error })
|
|
896
|
-
] }) }) });
|
|
897
|
-
}
|
|
898
|
-
if (!blob) {
|
|
899
|
-
return /* @__PURE__ */ jsx(Fragment, { children: loading ?? /* @__PURE__ */ jsx("div", { className: "grid h-full place-items-center text-sm text-muted-foreground", children: "Loading the original\u2026" }) });
|
|
900
|
-
}
|
|
901
|
-
const title = doc.file_name ?? doc.external_id;
|
|
902
|
-
const body = (() => {
|
|
903
|
-
switch (kind) {
|
|
904
|
-
case "pdf":
|
|
905
|
-
return /* @__PURE__ */ jsx(
|
|
906
|
-
PdfViewer,
|
|
907
|
-
{
|
|
908
|
-
file: blob,
|
|
909
|
-
assets: pdfAssets,
|
|
910
|
-
onPageChange,
|
|
911
|
-
currentPage,
|
|
912
|
-
scrollTrigger,
|
|
913
|
-
onLoadSuccess
|
|
914
|
-
}
|
|
915
|
-
);
|
|
916
|
-
case "docx":
|
|
917
|
-
return /* @__PURE__ */ jsx(DocxViewer, { blob });
|
|
918
|
-
case "xlsx":
|
|
919
|
-
return /* @__PURE__ */ jsx(XlsxViewer, { blob });
|
|
920
|
-
case "image":
|
|
921
|
-
return /* @__PURE__ */ jsx(ImageViewer, { blob, alt: title });
|
|
922
|
-
case "audio":
|
|
923
|
-
return /* @__PURE__ */ jsx(AudioViewer, { blob, title });
|
|
924
|
-
case "video":
|
|
925
|
-
return /* @__PURE__ */ jsx(VideoViewer, { blob, title });
|
|
926
|
-
default:
|
|
927
|
-
return null;
|
|
928
|
-
}
|
|
929
|
-
})();
|
|
930
|
-
return className ? /* @__PURE__ */ jsx("div", { className, "data-testid": "document-viewer", children: body }) : body;
|
|
931
|
-
}
|
|
932
813
|
function inlineFootnotes(content, footnotes) {
|
|
933
814
|
if (!footnotes || Object.keys(footnotes).length === 0) return content;
|
|
934
815
|
let result = content;
|
|
@@ -1019,6 +900,6 @@ function computeSelectionRuns(pages, selectedChunks) {
|
|
|
1019
900
|
return runs;
|
|
1020
901
|
}
|
|
1021
902
|
|
|
1022
|
-
export {
|
|
903
|
+
export { DocxViewer, INITIAL_LAZY_LOAD_BUFFER, LAZY_LOAD_BUFFER_AFTER, LAZY_LOAD_BUFFER_BEFORE, MAX_ZOOM, MIN_ZOOM, PAGE_SELECTOR, PdfViewer, XlsxViewer, anchorDelta, anchoredScroll, clampZoom, computeSelectionRuns, cycleZoom, doubleTapZoom, pinchZoom, renderDpr, usePageIntersectionObserver, usePinchZoom, useProcessedChunks, useScrollAnchor, zoomLabel };
|
|
1023
904
|
//# sourceMappingURL=index.js.map
|
|
1024
905
|
//# sourceMappingURL=index.js.map
|