teamsync-pdf-viewer 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/LICENSE +96 -1
  3. package/README.md +186 -165
  4. package/dist/src/annotations/AnnotationManager.d.ts +90 -0
  5. package/dist/src/annotations/geometry.d.ts +51 -0
  6. package/dist/src/annotations/ids.d.ts +6 -0
  7. package/dist/src/annotations/types.d.ts +72 -0
  8. package/dist/src/annotations/xfdf.d.ts +18 -0
  9. package/dist/src/components/AboutModal.d.ts +6 -0
  10. package/dist/src/components/AnnotationContextMenu.d.ts +17 -0
  11. package/dist/src/components/DocumentViewer.d.ts +50 -0
  12. package/dist/src/components/Header.d.ts +36 -0
  13. package/dist/src/components/InsertLinkModal.d.ts +10 -0
  14. package/dist/src/components/LeftSidebar.d.ts +10 -0
  15. package/dist/src/components/PageContextMenu.d.ts +20 -0
  16. package/dist/src/components/PageRenderer.d.ts +40 -0
  17. package/dist/src/components/SettingsModal.d.ts +8 -0
  18. package/dist/src/components/Sidebar.d.ts +18 -0
  19. package/dist/src/components/TeamSyncViewer.d.ts +35 -0
  20. package/dist/src/components/TextSelectionMenu.d.ts +18 -0
  21. package/dist/src/core/ViewerInstance.d.ts +94 -0
  22. package/dist/src/core/busContext.d.ts +3 -0
  23. package/dist/src/core/createWebViewer.d.ts +5 -0
  24. package/dist/src/core/eventBus.d.ts +25 -0
  25. package/dist/src/core/export.d.ts +23 -0
  26. package/dist/src/core/pdfAssets.d.ts +27 -0
  27. package/dist/src/core/print.d.ts +12 -0
  28. package/dist/src/core/types.d.ts +108 -0
  29. package/dist/src/hooks/usePdfSearch.d.ts +23 -0
  30. package/dist/src/hooks/useShortcuts.d.ts +13 -0
  31. package/dist/src/hooks/useViewerBus.d.ts +7 -0
  32. package/dist/src/index.d.ts +29 -0
  33. package/dist/src/plugins/index.d.ts +1 -0
  34. package/dist/src/plugins/types.d.ts +26 -0
  35. package/dist/src/utils/findRegexRedactions.d.ts +6 -0
  36. package/dist/src/utils/rotationUtils.d.ts +32 -0
  37. package/dist/style.css +2 -0
  38. package/dist/teamsync-pdf-viewer.js +6177 -0
  39. package/dist/teamsync-pdf-viewer.js.map +1 -0
  40. package/package.json +48 -15
  41. package/dist/TeamSync.pdf +0 -0
  42. package/dist/ThirdPartyNotices.txt +0 -639
  43. package/dist/favicon.svg +0 -16
  44. package/dist/icons.svg +0 -24
  45. package/dist/index.d.ts +0 -1
  46. package/dist/teamsync-pdf-viewer.css +0 -2
  47. package/dist/teamsync-pdf-viewer.es.js +0 -51524
  48. package/dist/teamsync-pdf-viewer.umd.cjs +0 -327
  49. package/dist/webviewer.js +0 -92
@@ -0,0 +1,90 @@
1
+ import { PDFDocumentProxy } from 'pdfjs-dist';
2
+ import { Annotation, AnnotationInput } from './types';
3
+ import { XfdfExportOptions } from './xfdf';
4
+ export type AnnotationAction = 'add' | 'modify' | 'delete';
5
+ export interface AnnotationChangedEvent {
6
+ annotations: Annotation[];
7
+ action: AnnotationAction;
8
+ /** True when the change came from importAnnotations()/programmatic APIs flagged as imported. */
9
+ imported: boolean;
10
+ }
11
+ export interface CommitOptions {
12
+ /** Mark the change as an import round-trip (not persisted by host bridges, not undoable). */
13
+ imported?: boolean;
14
+ /** Bypass read-only / authorship checks (programmatic host operations). */
15
+ force?: boolean;
16
+ /** Record in the undo history (default: true unless imported). */
17
+ undoable?: boolean;
18
+ }
19
+ export interface ViewerUserInfo {
20
+ id?: string;
21
+ name?: string;
22
+ }
23
+ type ChangedListener = (event: AnnotationChangedEvent) => void;
24
+ export declare class AnnotationManager {
25
+ private list;
26
+ private past;
27
+ private future;
28
+ private changedListeners;
29
+ private listListeners;
30
+ private user;
31
+ private readOnly;
32
+ private canEditOthers;
33
+ private resolver;
34
+ setDocument(doc: PDFDocumentProxy | null): void;
35
+ hasDocument(): boolean;
36
+ setCurrentUser(name: string, id?: string): void;
37
+ setCurrentUserInfo(user: ViewerUserInfo | undefined): void;
38
+ getCurrentUser(): string;
39
+ getCurrentUserInfo(): ViewerUserInfo;
40
+ setReadOnly(readOnly: boolean): void;
41
+ isReadOnly(): boolean;
42
+ /** Allow editing/deleting annotations authored by other users (default false). */
43
+ setCanEditOthers(value: boolean): void;
44
+ /** Whether the current user may modify or delete this annotation through the UI. */
45
+ canEdit(a: Annotation): boolean;
46
+ canAdd(): boolean;
47
+ /** The current list. The array reference is stable until the next change. */
48
+ getAnnotationsList(): Annotation[];
49
+ getAnnotationById(id: string): Annotation | undefined;
50
+ /** React `useSyncExternalStore` pair. */
51
+ subscribe: (listener: () => void) => (() => void);
52
+ getSnapshot: () => Annotation[];
53
+ addEventListener(type: 'annotationChanged', listener: ChangedListener): () => void;
54
+ removeEventListener(type: 'annotationChanged', listener: ChangedListener): void;
55
+ /** Apryse-compat no-op: React re-renders from the list. */
56
+ drawAnnotationsFromList(_annotations: Annotation[]): void;
57
+ get canUndo(): boolean;
58
+ get canRedo(): boolean;
59
+ undo(): boolean;
60
+ redo(): boolean;
61
+ /**
62
+ * Replace the whole list (the UI's edit path). Diffs against the current list, enforces
63
+ * permissions (rejected edits keep the previous version), records history and emits one
64
+ * `annotationChanged` event per action.
65
+ */
66
+ commit(next: Annotation[], opts?: CommitOptions): Annotation[];
67
+ addAnnotations(inputs: AnnotationInput[], opts?: CommitOptions): Annotation[];
68
+ updateAnnotation(id: string, patch: Partial<AnnotationInput>, opts?: CommitOptions): Annotation | undefined;
69
+ deleteAnnotations(targets: Array<Annotation | string>, opts?: CommitOptions): void;
70
+ /** Remove every annotation (e.g. on document switch). Not undoable, emits deletes as imported. */
71
+ clear(): void;
72
+ /**
73
+ * Import an XFDF document or bare fragments. Annotations whose `name` already exists are
74
+ * replaced (modify), new ones added; the change is flagged `imported` and is not undoable.
75
+ * Returns the imported annotations as they now exist in the list.
76
+ */
77
+ importAnnotations(xfdf: string): Promise<Annotation[]>;
78
+ /**
79
+ * Export as XFDF. With `annotList`, returns the bare fragment(s) for those annotations (the
80
+ * form hosts persist per annotation); without it, a complete XFDF document.
81
+ */
82
+ exportAnnotations(opts?: XfdfExportOptions): Promise<string>;
83
+ /** Legacy bespoke JSON export (pre-1.2 `exportAnnotations()` shape). */
84
+ exportAnnotationsLegacyJson(): string;
85
+ private requireResolver;
86
+ private apply;
87
+ private stampNew;
88
+ private emit;
89
+ }
90
+ export {};
@@ -0,0 +1,51 @@
1
+ import { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
2
+ export type Matrix = [number, number, number, number, number, number];
3
+ export interface PageGeometry {
4
+ /** 1-based page number */
5
+ pageNumber: number;
6
+ /** PDF user-space bounding box [x0, y0, x1, y1] (the CropBox pdf.js renders). */
7
+ viewBox: [number, number, number, number];
8
+ /** Intrinsic page rotation (/Rotate), normalized to 0/90/180/270. */
9
+ rotate: number;
10
+ /** Base page size in points (already swapped for 90/270). */
11
+ width: number;
12
+ height: number;
13
+ /** Base-space (viewer) -> PDF user-space transform is the inverse of this viewport transform. */
14
+ transform: Matrix;
15
+ }
16
+ export interface Rect {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ }
22
+ export interface Point {
23
+ x: number;
24
+ y: number;
25
+ }
26
+ /** PDF rectangle as XFDF writes it: [llx, lly, urx, ury]. */
27
+ export type PdfRect = [number, number, number, number];
28
+ /** Build the geometry for a page from its viewBox and intrinsic rotation (mirrors pdf.js PageViewport at scale 1). */
29
+ export declare function createPageGeometry(pageNumber: number, viewBox: [number, number, number, number], rotate: number): PageGeometry;
30
+ export declare function geometryFromPage(page: PDFPageProxy): PageGeometry;
31
+ /** Small per-document cache so callers can resolve geometry for many annotations cheaply. */
32
+ export declare function createGeometryResolver(pdfDoc: PDFDocumentProxy): (pageNumber: number) => Promise<PageGeometry>;
33
+ export type GeometryResolver = (pageNumber: number) => Promise<PageGeometry>;
34
+ export declare function toPdfPoint(g: PageGeometry, p: Point): Point;
35
+ export declare function fromPdfPoint(g: PageGeometry, p: Point): Point;
36
+ /** Viewer rect (top-left origin) -> PDF rect [llx, lly, urx, ury]. */
37
+ export declare function rectToPdf(g: PageGeometry, r: Rect): PdfRect;
38
+ /** PDF rect [llx, lly, urx, ury] -> viewer rect (top-left origin). */
39
+ export declare function rectFromPdf(g: PageGeometry, r: PdfRect): Rect;
40
+ export declare function pathToPdf(g: PageGeometry, points: Point[]): Point[];
41
+ export declare function pathFromPdf(g: PageGeometry, points: Point[]): Point[];
42
+ /**
43
+ * XFDF QuadPoints for a viewer rect: x1,y1 (upper-left) x2,y2 (upper-right) x3,y3 (lower-left)
44
+ * x4,y4 (lower-right) in PDF space — the order Acrobat and Apryse write for text markup.
45
+ */
46
+ export declare function rectToQuadPoints(g: PageGeometry, r: Rect): number[];
47
+ /** Bounding viewer rect of one or more XFDF quads (8 numbers each). */
48
+ export declare function quadPointsToRects(g: PageGeometry, quads: number[]): Rect[];
49
+ export declare function unionRects(rects: Rect[]): Rect;
50
+ /** Round to 3 decimals for XFDF output (Apryse writes 3, Acrobat up to 6). */
51
+ export declare const fmt: (n: number) => string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
3
+ * Stable, collision-free annotation ids. They double as the XFDF `name` attribute, which hosts use
4
+ * to match persisted rows to live annotations, so they must never be timestamps.
5
+ */
6
+ export declare function newAnnotationId(): string;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
3
+ * Annotation data model.
4
+ *
5
+ * Coordinates are in "base page space": the pdf.js viewport at scale 1 with the page's intrinsic
6
+ * /Rotate applied (top-left origin, PDF points). UI rotation applied by the viewer is composed on
7
+ * top of this space at render time, so stored annotations are independent of the current view.
8
+ */
9
+ export type AnnotationType = 'rectangle' | 'ellipse' | 'line' | 'arrow' | 'freehand' | 'text' | 'note' | 'callout' | 'signature' | 'highlight' | 'digital_signature_placeholder' | 'link'
10
+ /**
11
+ * An annotation imported from XFDF that this viewer cannot edit or render natively (e.g.
12
+ * underline, squiggly, polygon, redaction). It is drawn as a read-only outline at its bounding
13
+ * box and re-exported verbatim (`rawXfdf`) so nothing is lost on a save round-trip.
14
+ */
15
+ | 'opaque';
16
+ export interface AnnotationPoint {
17
+ x: number;
18
+ y: number;
19
+ }
20
+ export interface Annotation {
21
+ id: string;
22
+ /** 1-based page number */
23
+ pageIndex: number;
24
+ type: AnnotationType;
25
+ x: number;
26
+ y: number;
27
+ width: number;
28
+ height: number;
29
+ text?: string;
30
+ points?: AnnotationPoint[];
31
+ rects?: {
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
36
+ }[];
37
+ color: string;
38
+ strokeWidth: number;
39
+ opacity: number;
40
+ imageUrl?: string;
41
+ timestamp?: number;
42
+ signer?: string;
43
+ signType?: 'advanced' | 'simple';
44
+ linkUrl?: string;
45
+ /** Display name of the author (set from `currentUser` when created in-viewer). */
46
+ author?: string;
47
+ /** Stable author identifier (opaque to the viewer). */
48
+ authorId?: string;
49
+ /** When true the annotation cannot be moved, edited or deleted in the UI. */
50
+ readOnly?: boolean;
51
+ /** Multi-stroke ink (each stroke a polyline). `points` holds the first stroke for legacy consumers. */
52
+ strokes?: AnnotationPoint[][];
53
+ /** ISO-8601 timestamps (XFDF creationdate / date). */
54
+ createdAt?: string;
55
+ modifiedAt?: string;
56
+ /** Subject / XFDF element name of an opaque annotation (informational). */
57
+ opaqueKind?: string;
58
+ /** Verbatim XFDF element for `opaque` annotations. */
59
+ rawXfdf?: string;
60
+ /**
61
+ * XFDF attributes and child elements this viewer does not model (e.g. Apryse `trn-custom-data`,
62
+ * `defaultappearance`). Preserved on import and re-emitted on export so other viewers keep
63
+ * their metadata across a round-trip.
64
+ */
65
+ xfdfExtras?: {
66
+ attrs?: Record<string, string>;
67
+ children?: string[];
68
+ };
69
+ }
70
+ export type AnnotationInput = Omit<Annotation, 'id'> & {
71
+ id?: string;
72
+ };
@@ -0,0 +1,18 @@
1
+ import { Annotation } from './types';
2
+ import { GeometryResolver } from './geometry';
3
+ export declare const XFDF_NS = "http://ns.adobe.com/xfdf/";
4
+ export interface XfdfExportOptions {
5
+ /** Annotations to serialize (default: all given). */
6
+ annotList?: Annotation[];
7
+ /** Write the author's display name into `title` (default true). */
8
+ useDisplayAuthor?: boolean;
9
+ }
10
+ /** ISO-8601 -> PDF date `D:YYYYMMDDHHmmSS+HH'mm'`. */
11
+ export declare function toPdfDate(iso: string | undefined): string;
12
+ /** PDF date -> ISO-8601 (best effort; returns undefined when unparseable). */
13
+ export declare function fromPdfDate(pdf: string | null | undefined): string | undefined;
14
+ /** Serialize one annotation to an XFDF element (no envelope). */
15
+ export declare function annotationToXfdfFragment(a: Annotation, resolve: GeometryResolver, opts?: XfdfExportOptions): Promise<string>;
16
+ /** Serialize annotations to a complete XFDF document. */
17
+ export declare function annotationsToXfdf(annotations: Annotation[], resolve: GeometryResolver, opts?: XfdfExportOptions): Promise<string>;
18
+ export declare function parseXfdf(xml: string, resolve: GeometryResolver): Promise<Annotation[]>;
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ interface AboutModalProps {
3
+ onClose: () => void;
4
+ }
5
+ export default function AboutModal({ onClose }: AboutModalProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ import { Annotation } from '../annotations/types';
3
+ import { SDKPermissions } from '../core/types';
4
+ interface AnnotationContextMenuProps {
5
+ annotation: Annotation;
6
+ position: {
7
+ top: number;
8
+ left: number;
9
+ };
10
+ onCopy: () => void;
11
+ onDelete: () => void;
12
+ onUpdateColor: (color: string) => void;
13
+ onOpenLinkModal: () => void;
14
+ permissions?: SDKPermissions;
15
+ }
16
+ export default function AnnotationContextMenu({ annotation, position, onCopy, onDelete, onUpdateColor, onOpenLinkModal, permissions }: AnnotationContextMenuProps): React.JSX.Element;
17
+ export {};
@@ -0,0 +1,50 @@
1
+ import { default as React } from 'react';
2
+ import { Annotation } from '../annotations/types';
3
+ import { AnnotationManager } from '../annotations/AnnotationManager';
4
+ import { Redaction, WatermarkOptions, SDKPermissions, PdfAssetPaths } from '../core/types';
5
+ import * as pdfjsLib from 'pdfjs-dist';
6
+ export interface DocumentLoadErrorInfo {
7
+ url: string;
8
+ passwordRequired: boolean;
9
+ }
10
+ interface DocumentViewerProps {
11
+ leftSidebarOpen: boolean;
12
+ rightSidebarOpen: boolean;
13
+ activeTab: string;
14
+ /** Canonical annotation list, history, permissions and XFDF (owned by the viewer instance). */
15
+ annotationManager: AnnotationManager;
16
+ initialDoc?: string;
17
+ /** Bump to force a reload of the same URL (retry after a load error). */
18
+ loadNonce?: number;
19
+ /** Send cookies with the document request. */
20
+ withCredentials?: boolean;
21
+ /** pdf.js asset locations, applied right before the document is opened. */
22
+ assets?: PdfAssetPaths;
23
+ /** Render the thumbnails (left) and comments/search (right) panels. Default true. */
24
+ sidebars?: boolean;
25
+ redactions?: Redaction[];
26
+ regexRedactions?: RegExp[];
27
+ scale: number;
28
+ setScale: (scale: number | ((prev: number) => number)) => void;
29
+ sidebarTab: 'Comments' | 'Search';
30
+ setSidebarTab: (tab: 'Comments' | 'Search') => void;
31
+ onAnnotationsChange?: (annotations: Annotation[]) => void;
32
+ /** Reports the combined (prop + regex + manual) redaction list whenever it changes. */
33
+ onRedactionsChange?: (redactions: Redaction[]) => void;
34
+ onDocumentLoaded?: (doc: pdfjsLib.PDFDocumentProxy, url: string) => void;
35
+ onLoadError?: (error: Error, info: DocumentLoadErrorInfo) => void;
36
+ /** Fires once per loaded document, after the first page canvas has been painted. */
37
+ onFirstPageRendered?: (pageNumber: number) => void;
38
+ onPageChange?: (pageNumber: number, numPages: number) => void;
39
+ pageTransition: 'continuous' | 'page-by-page';
40
+ pageLayout: 'single' | 'double' | 'cover-facing';
41
+ rotation: number;
42
+ setRotation: (r: number | ((prev: number) => number)) => void;
43
+ watermark?: WatermarkOptions;
44
+ watermarkText?: string;
45
+ enableAnnotations?: boolean;
46
+ initialPage?: number;
47
+ permissions?: SDKPermissions;
48
+ }
49
+ export default function DocumentViewer({ leftSidebarOpen, rightSidebarOpen, activeTab, annotationManager, initialDoc, loadNonce, withCredentials, assets, sidebars, redactions, regexRedactions, scale, setScale, sidebarTab, setSidebarTab, onAnnotationsChange, onRedactionsChange, onDocumentLoaded, onLoadError, onFirstPageRendered, onPageChange, pageTransition, pageLayout, rotation, setRotation, watermark, watermarkText, enableAnnotations: _enableAnnotations, initialPage, permissions }: DocumentViewerProps): React.JSX.Element;
50
+ export {};
@@ -0,0 +1,36 @@
1
+ import { default as React } from 'react';
2
+ import { SDKPermissions } from '../core/types';
3
+ import { ViewerPlugin } from '../plugins/types';
4
+ interface HeaderProps {
5
+ activeTab: string;
6
+ setActiveTab: (tab: string) => void;
7
+ leftSidebarOpen: boolean;
8
+ setLeftSidebarOpen: (open: boolean) => void;
9
+ rightSidebarOpen: boolean;
10
+ setRightSidebarOpen: (open: boolean) => void;
11
+ sidebarTab: 'Comments' | 'Search';
12
+ scale: number;
13
+ onZoomIn: () => void;
14
+ onZoomOut: () => void;
15
+ onZoomSet: (scale: number) => void;
16
+ onDownload: () => void;
17
+ onFullScreen: () => void;
18
+ onSaveAs: () => void;
19
+ onPrint?: () => void;
20
+ onOpenSettings: () => void;
21
+ onOpenAbout: () => void;
22
+ onOpenSidebarTab: (tab: 'Comments' | 'Search') => void;
23
+ pageTransition: 'continuous' | 'page-by-page';
24
+ setPageTransition: (t: 'continuous' | 'page-by-page') => void;
25
+ pageLayout: 'single' | 'double' | 'cover-facing';
26
+ setPageLayout: (l: 'single' | 'double' | 'cover-facing') => void;
27
+ rotation: number;
28
+ setRotation: (r: number) => void;
29
+ signatureCount?: number;
30
+ enableAnnotations?: boolean;
31
+ enableSign?: boolean;
32
+ plugins?: ViewerPlugin[];
33
+ permissions?: SDKPermissions;
34
+ }
35
+ export default function Header({ activeTab, setActiveTab, leftSidebarOpen, setLeftSidebarOpen, rightSidebarOpen, setRightSidebarOpen: _setRightSidebarOpen, sidebarTab, scale, onZoomIn, onZoomOut, onZoomSet, onDownload, onFullScreen, onSaveAs, onPrint, onOpenSettings, onOpenAbout, onOpenSidebarTab, pageTransition, setPageTransition, pageLayout, setPageLayout, rotation, setRotation, signatureCount, enableAnnotations, enableSign, plugins, permissions }: HeaderProps): React.JSX.Element;
36
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ interface InsertLinkModalProps {
3
+ initialUrl?: string;
4
+ initialText?: string;
5
+ showTextInput?: boolean;
6
+ onClose: () => void;
7
+ onSave: (url: string, text?: string) => void;
8
+ }
9
+ export default function InsertLinkModal({ initialUrl, initialText, showTextInput, onClose, onSave }: InsertLinkModalProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import * as pdfjsLib from 'pdfjs-dist';
3
+ interface LeftSidebarProps {
4
+ isOpen: boolean;
5
+ pdfDoc: pdfjsLib.PDFDocumentProxy | null;
6
+ pageNum: number;
7
+ setPageNum: (p: number) => void;
8
+ }
9
+ export default function LeftSidebar({ isOpen, pdfDoc, pageNum, setPageNum }: LeftSidebarProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,20 @@
1
+ import { default as React } from 'react';
2
+ interface PageContextMenuProps {
3
+ position: {
4
+ top: number;
5
+ left: number;
6
+ };
7
+ hasSelection?: boolean;
8
+ onSetTool: (tool: any) => void;
9
+ onZoomIn: () => void;
10
+ onZoomOut: () => void;
11
+ onClose: () => void;
12
+ onLink?: () => void;
13
+ onHighlight?: () => void;
14
+ onUnderline?: () => void;
15
+ onStrikethrough?: () => void;
16
+ onCopy?: () => void;
17
+ enableAnnotations?: boolean;
18
+ }
19
+ export default function PageContextMenu({ position, hasSelection, onSetTool, onZoomIn, onZoomOut, onClose, onLink, onHighlight, onUnderline, onStrikethrough, onCopy, enableAnnotations }: PageContextMenuProps): React.JSX.Element;
20
+ export {};
@@ -0,0 +1,40 @@
1
+ import { default as React } from 'react';
2
+ import { SearchResult } from '../hooks/usePdfSearch';
3
+ import { Redaction, WatermarkOptions } from '../core/types';
4
+ import { Annotation } from '../annotations/types';
5
+ import * as pdfjsLib from 'pdfjs-dist';
6
+ export type { Annotation };
7
+ interface PageRendererProps {
8
+ pageNum: number;
9
+ pdfDoc: pdfjsLib.PDFDocumentProxy;
10
+ scale: number;
11
+ rotation: number;
12
+ containerWidth: number;
13
+ containerHeight: number;
14
+ scrollTop: number;
15
+ scrollLeft: number;
16
+ pageTop: number;
17
+ pageLeft?: number;
18
+ basePageWidth: number;
19
+ basePageHeight: number;
20
+ activeTab: string;
21
+ activeTool: string | null;
22
+ annotations: Annotation[];
23
+ selectedAnnotationId: string | null;
24
+ activeSearchResult: SearchResult | null;
25
+ onMouseDown: (e: React.MouseEvent<Element>, pageNum: number) => void;
26
+ onMouseMove: (e: React.MouseEvent<Element>, pageNum: number) => void;
27
+ onMouseUp: (e: React.MouseEvent<Element>, pageNum: number) => void;
28
+ onAnnotationClick: (id: string, e: React.MouseEvent) => void;
29
+ onAnnotationMouseEnter: (id: string) => void;
30
+ onClearSelection: () => void;
31
+ watermark?: WatermarkOptions;
32
+ watermarkText?: string;
33
+ redactions?: Redaction[];
34
+ onDiscardRedaction?: (redaction: Redaction) => void;
35
+ /** Called after the page canvas has been painted (used for first-page-rendered telemetry). */
36
+ onRendered?: (pageNum: number) => void;
37
+ }
38
+ declare function PageRendererComponent({ pageNum, pdfDoc, scale, rotation, containerWidth: _containerWidth, containerHeight: _containerHeight, scrollTop: _scrollTop, scrollLeft: _scrollLeft, pageTop, pageLeft, basePageWidth, basePageHeight, activeTab, activeTool, annotations, selectedAnnotationId, activeSearchResult, onMouseDown, onMouseMove, onMouseUp, onAnnotationClick, onAnnotationMouseEnter, onClearSelection, watermark, watermarkText, redactions, onDiscardRedaction, onRendered }: PageRendererProps): React.JSX.Element;
39
+ declare const PageRenderer: React.MemoExoticComponent<typeof PageRendererComponent>;
40
+ export default PageRenderer;
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ interface SettingsModalProps {
3
+ onClose: () => void;
4
+ watermarkText: string;
5
+ setWatermarkText: (text: string) => void;
6
+ }
7
+ export default function SettingsModal({ onClose, watermarkText, setWatermarkText }: SettingsModalProps): React.JSX.Element;
8
+ export {};
@@ -0,0 +1,18 @@
1
+ import { default as React } from 'react';
2
+ import { SearchResult } from '../hooks/usePdfSearch';
3
+ interface SidebarProps {
4
+ isOpen: boolean;
5
+ annotations: any[];
6
+ setAnnotations: (anns: any[]) => void;
7
+ selectedAnnotationId: string | null;
8
+ setSelectedAnnotationId: (id: string | null) => void;
9
+ onSearch: (query: string) => void;
10
+ searchResults: SearchResult[];
11
+ isSearching: boolean;
12
+ searchProgress: number;
13
+ onResultClick: (result: SearchResult) => void;
14
+ activeTab: 'Comments' | 'Search';
15
+ setActiveTab: (tab: 'Comments' | 'Search') => void;
16
+ }
17
+ export default function Sidebar({ isOpen, annotations, setAnnotations, selectedAnnotationId, setSelectedAnnotationId, onSearch, searchResults, isSearching, searchProgress, onResultClick, activeTab, setActiveTab }: SidebarProps): React.JSX.Element;
18
+ export {};
@@ -0,0 +1,35 @@
1
+ import { default as React } from 'react';
2
+ import { DocumentLoadErrorInfo } from './DocumentViewer';
3
+ import { WebViewerInstance } from '../core/ViewerInstance';
4
+ import { WebViewerOptions } from '../core/types';
5
+ import { Annotation } from '../annotations/types';
6
+ export interface TeamSyncViewerProps extends Omit<WebViewerOptions, 'path'> {
7
+ /** URL of the PDF to display. Alias of `initialDoc`; `fileUrl` wins when both are set. */
8
+ fileUrl?: string;
9
+ /** Fires once, after mount, with the instance handle. */
10
+ onReady?: (instance: WebViewerInstance) => void;
11
+ onDocumentLoaded?: (info: {
12
+ url: string;
13
+ numPages: number;
14
+ }) => void;
15
+ /**
16
+ * Fires when the document could not be loaded. `retry(newUrl?)` reloads — pass a fresh URL when
17
+ * the previous one was a presigned link that expired.
18
+ */
19
+ onDocumentLoadError?: (error: Error, retry: (newUrl?: string) => void, info: DocumentLoadErrorInfo) => void;
20
+ /** Fires once per document, after the first page canvas has been painted. */
21
+ onFirstPageRendered?: (info: {
22
+ url: string;
23
+ pageNumber: number;
24
+ }) => void;
25
+ /** Fires (in addition to onDocumentLoadError) when the document is password protected. */
26
+ onPasswordRequired?: (info: {
27
+ url: string;
28
+ }) => void;
29
+ onPageChange?: (pageNumber: number, numPages: number) => void;
30
+ onAnnotationsChange?: (annotations: Annotation[]) => void;
31
+ className?: string;
32
+ style?: React.CSSProperties;
33
+ }
34
+ export declare const TeamSyncViewer: React.ForwardRefExoticComponent<TeamSyncViewerProps & React.RefAttributes<WebViewerInstance>>;
35
+ export default TeamSyncViewer;
@@ -0,0 +1,18 @@
1
+ import { default as React } from 'react';
2
+ import { SDKPermissions } from '../core/types';
3
+ interface TextSelectionMenuProps {
4
+ position: {
5
+ top: number;
6
+ left: number;
7
+ };
8
+ onHighlight: () => void;
9
+ onText?: () => void;
10
+ onRedact?: () => void;
11
+ onCopy?: () => void;
12
+ onLink?: () => void;
13
+ permissions?: SDKPermissions;
14
+ isViewMode?: boolean;
15
+ hasText?: boolean;
16
+ }
17
+ export default function TextSelectionMenu({ position, onHighlight, onText, onRedact, onCopy, onLink, permissions, isViewMode, hasText }: TextSelectionMenuProps): React.JSX.Element | null;
18
+ export {};
@@ -0,0 +1,94 @@
1
+ import { ViewerBus } from './eventBus';
2
+ import { ExportOptions } from './export';
3
+ import { Annotation } from '../annotations/types';
4
+ import { AnnotationManager } from '../annotations/AnnotationManager';
5
+ import { Redaction, WatermarkOptions, ViewerEventMap, ViewerEventType } from './types';
6
+ /**
7
+ * © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
8
+ * WebViewerInstance — the imperative handle returned by `createWebViewer()` and exposed through
9
+ * `<TeamSyncViewer ref>`. Keeps the legacy `UI` / `Core` facade for drop-in compatibility.
10
+ */
11
+ import type * as pdfjsLib from 'pdfjs-dist';
12
+ /** Callbacks the React component installs so the instance can reach live state. */
13
+ export interface ViewerBinding {
14
+ getAnnotations(): Annotation[];
15
+ getRedactions(): Redaction[];
16
+ getWatermark(): WatermarkOptions | undefined;
17
+ getPdfDocument(): pdfjsLib.PDFDocumentProxy | null;
18
+ getDocumentUrl(): string | undefined;
19
+ getFileName(): string | undefined;
20
+ getCurrentUserName(): string | undefined;
21
+ getCurrentPage(): number;
22
+ getPageCount(): number;
23
+ loadDocument(url: string): void;
24
+ }
25
+ export declare class WebViewerInstance {
26
+ readonly bus: ViewerBus;
27
+ /** Annotation list, history, permissions and XFDF import/export. */
28
+ readonly annotationManager: AnnotationManager;
29
+ /** Root element of the viewer once mounted. */
30
+ element: HTMLElement | null;
31
+ private binding;
32
+ private unmountRoot;
33
+ private destroyed;
34
+ constructor(bus: ViewerBus, annotationManager?: AnnotationManager);
35
+ /** @internal */
36
+ _bind(binding: ViewerBinding, element: HTMLElement | null): void;
37
+ /** @internal */
38
+ _unbind(): void;
39
+ /** @internal — installed by createWebViewer() so destroy() can unmount the React root. */
40
+ _setUnmount(fn: () => void): void;
41
+ get isDestroyed(): boolean;
42
+ get isMounted(): boolean;
43
+ /**
44
+ * Tear the viewer down: unmounts the React tree created by `createWebViewer()`, drops every
45
+ * listener and refuses further use. Safe to call twice.
46
+ */
47
+ destroy(): void;
48
+ on<K extends ViewerEventType>(type: K, listener: (detail: ViewerEventMap[K]) => void): () => void;
49
+ off<K extends ViewerEventType>(type: K, listener: (detail: ViewerEventMap[K]) => void): void;
50
+ /** Load (or reload) a document by URL. Resolves when loaded, rejects on load error. */
51
+ loadDocument(url: string): Promise<{
52
+ url: string;
53
+ numPages: number;
54
+ }>;
55
+ getDocumentUrl(): string | undefined;
56
+ getPdfDocument(): pdfjsLib.PDFDocumentProxy | null;
57
+ getCurrentPage(): number;
58
+ getPageCount(): number;
59
+ getAnnotations(): Annotation[];
60
+ /** Print the exported document (annotations, redactions and watermark baked in). */
61
+ print(): void;
62
+ /**
63
+ * Build the exported PDF (annotations + watermark baked, redacted pages rasterized).
64
+ * Uses the bytes of the loaded document; never re-fetches the URL.
65
+ */
66
+ getFileData(options?: ExportOptions): Promise<Uint8Array>;
67
+ readonly UI: {
68
+ /** Theming is not implemented; kept for API compatibility. */
69
+ setTheme: (_theme: string) => void;
70
+ openElements: (elements: string[]) => void;
71
+ closeElements: (elements: string[]) => void;
72
+ enableElements: (elements: string[]) => void;
73
+ disableElements: (elements: string[]) => void;
74
+ setActiveLeftPanel: (panel: string) => void;
75
+ setToolMode: (tool: string | null) => void;
76
+ fitWidth: () => void;
77
+ fitPage: () => void;
78
+ fitToWidth: () => void;
79
+ fitToPage: () => void;
80
+ };
81
+ readonly Core: {
82
+ /** The real AnnotationManager (XFDF import/export, granular events, permissions). */
83
+ readonly annotationManager: AnnotationManager;
84
+ documentViewer: {
85
+ addEventListener: (event: string, callback: (detail: unknown) => void) => (() => void);
86
+ removeEventListener: (event: string, callback: (detail: unknown) => void) => void;
87
+ getCurrentPage: () => number;
88
+ getPageCount: () => number;
89
+ getDocument: () => {
90
+ getFileData: (options?: ExportOptions) => Promise<Uint8Array<ArrayBufferLike>>;
91
+ };
92
+ };
93
+ };
94
+ }
@@ -0,0 +1,3 @@
1
+ import { ViewerBus } from './eventBus';
2
+ /** Provided by <TeamSyncViewer>; every internal component reads its bus from here. */
3
+ export declare const ViewerBusContext: import('react').Context<ViewerBus | null>;
@@ -0,0 +1,5 @@
1
+ import { WebViewerInstance } from './ViewerInstance';
2
+ import { WebViewerOptions } from './types';
3
+ export declare function createWebViewer(options: WebViewerOptions, viewerElement: HTMLElement): Promise<WebViewerInstance>;
4
+ /** @deprecated Use `createWebViewer`. Kept as an alias for drop-in compatibility. */
5
+ export declare const WebViewer: typeof createWebViewer;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
3
+ * Per-instance event bus.
4
+ *
5
+ * Replaces the former `window.dispatchEvent(new CustomEvent('action-*'))` plumbing so that several
6
+ * viewer instances can coexist on one page without cross-talk, and so that `destroy()` can drop
7
+ * every listener an instance ever registered.
8
+ */
9
+ export type BusListener<T = unknown> = (detail: T) => void;
10
+ export declare class ViewerBus {
11
+ private readonly listeners;
12
+ private destroyed;
13
+ /** Subscribe. Returns an unsubscribe function. */
14
+ on<T = unknown>(type: string, listener: BusListener<T>): () => void;
15
+ /** Subscribe for a single delivery. */
16
+ once<T = unknown>(type: string, listener: BusListener<T>): () => void;
17
+ off<T = unknown>(type: string, listener: BusListener<T>): void;
18
+ /** Dispatch synchronously to every listener. Listener errors are isolated and logged. */
19
+ emit<T = unknown>(type: string, detail?: T): void;
20
+ listenerCount(type?: string): number;
21
+ removeAll(): void;
22
+ /** Drop every listener and refuse further subscriptions/emissions. */
23
+ destroy(): void;
24
+ get isDestroyed(): boolean;
25
+ }