@react-pdf-kit/viewer 0.0.0-experimental.3 → 0.0.0-experimental.5

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 (150) hide show
  1. package/dist/{Combination-479e39c6.js → Combination-136ff99c.js} +184 -187
  2. package/dist/assets/style.css +1 -1
  3. package/dist/components/RPConfig.js +16 -6
  4. package/dist/components/RPController.js +3 -4
  5. package/dist/components/RPDropFileZone.js +35 -29
  6. package/dist/components/RPPages.js +76 -84
  7. package/dist/components/RPProvider.js +3 -4
  8. package/dist/components/layout/RPDefaultLayout.js +11 -10
  9. package/dist/components/layout/RPLayout.js +27 -25
  10. package/dist/components/layout/WrapperLayout.js +10 -11
  11. package/dist/components/layout/sidebar/RPSidebar.js +7 -8
  12. package/dist/components/layout/sidebar/Thumbnail.js +3 -4
  13. package/dist/components/layout/sidebar/Thumbnails.js +3 -4
  14. package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
  15. package/dist/components/layout/toolbar/DocumentDialog.js +8 -9
  16. package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
  17. package/dist/components/layout/toolbar/FileDownloadTool.js +9 -10
  18. package/dist/components/layout/toolbar/FileUploadTool.js +9 -10
  19. package/dist/components/layout/toolbar/FullScreenTool.js +6 -6
  20. package/dist/components/layout/toolbar/MenuItem.js +6 -6
  21. package/dist/components/layout/toolbar/MenuSeparator.js +6 -6
  22. package/dist/components/layout/toolbar/MostPageTool.js +9 -10
  23. package/dist/components/layout/toolbar/OtherTool.js +9 -10
  24. package/dist/components/layout/toolbar/Paginate.js +7 -8
  25. package/dist/components/layout/toolbar/PrintTool.js +9 -10
  26. package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
  27. package/dist/components/layout/toolbar/RPMoreOptions.js +9 -10
  28. package/dist/components/layout/toolbar/RPToolbar.js +9 -10
  29. package/dist/components/layout/toolbar/RPToolbarEnd.js +9 -10
  30. package/dist/components/layout/toolbar/RotateTool.js +9 -10
  31. package/dist/components/layout/toolbar/ScrollModeTool.js +6 -6
  32. package/dist/components/layout/toolbar/SearchCloseButton.js +4 -4
  33. package/dist/components/layout/toolbar/SearchResultNavigator.js +7 -8
  34. package/dist/components/layout/toolbar/SearchTool.js +11 -12
  35. package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
  36. package/dist/components/layout/toolbar/ThumbnailTool.js +7 -8
  37. package/dist/components/layout/toolbar/ToolbarCustom.js +3 -4
  38. package/dist/components/layout/toolbar/ToolbarDefault.js +9 -10
  39. package/dist/components/layout/toolbar/ToolbarLayout.js +9 -10
  40. package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
  41. package/dist/components/layout/toolbar/ZoomTool.js +9 -10
  42. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +8 -9
  43. package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
  44. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +11 -10
  45. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +7 -8
  46. package/dist/components/layout/toolbar/tools/FileUploadTool.js +7 -8
  47. package/dist/components/layout/toolbar/tools/FirstPageTool.js +11 -10
  48. package/dist/components/layout/toolbar/tools/FullScreenTool.js +4 -4
  49. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
  50. package/dist/components/layout/toolbar/tools/InputPageTool.js +7 -8
  51. package/dist/components/layout/toolbar/tools/LastPageTool.js +11 -10
  52. package/dist/components/layout/toolbar/tools/NextPageTool.js +7 -8
  53. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
  54. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +7 -8
  55. package/dist/components/layout/toolbar/tools/PrintTool.js +7 -8
  56. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +7 -8
  57. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +7 -8
  58. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +4 -4
  59. package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -4
  60. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +4 -4
  61. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +7 -8
  62. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
  63. package/dist/components/layout/toolbar/tools/ZoomInTool.js +7 -8
  64. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +19 -20
  65. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +7 -8
  66. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +9 -10
  67. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +7 -8
  68. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
  69. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +9 -10
  70. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +9 -10
  71. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
  72. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +9 -10
  73. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +9 -10
  74. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +9 -10
  75. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +6 -6
  76. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +6 -6
  77. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +6 -6
  78. package/dist/components/page/AnnotationLayer.js +24 -25
  79. package/dist/components/page/CanvasLayer.js +3 -4
  80. package/dist/components/page/CustomElement.js +3 -4
  81. package/dist/components/page/DualPage.js +3 -4
  82. package/dist/components/page/DualPageWithCover.js +3 -4
  83. package/dist/components/page/RPPage.js +4 -5
  84. package/dist/components/page/SinglePage.js +3 -4
  85. package/dist/components/page/TextHighlightLayer.js +15 -16
  86. package/dist/components/page/TextLayer.js +11 -12
  87. package/dist/components/ui/Checkbox.js +2 -2
  88. package/dist/components/ui/DropDown.js +6 -6
  89. package/dist/components/ui/LoadingIndicator.js +7 -8
  90. package/dist/components/ui/RPTooltip.js +411 -197
  91. package/dist/contexts/ConfigContext.js +5 -4
  92. package/dist/contexts/DimensionPagesContext.js +5 -6
  93. package/dist/contexts/DropFileZoneContext.js +4 -5
  94. package/dist/contexts/ElementPageContext.js +5 -6
  95. package/dist/contexts/FileInputContext.js +5 -6
  96. package/dist/contexts/HighlightContext.js +5 -6
  97. package/dist/contexts/LayoutDropFileZoneContext.js +11 -0
  98. package/dist/contexts/PagesRotateContext.js +5 -6
  99. package/dist/contexts/PaginationContext.js +5 -6
  100. package/dist/contexts/PrintContext.js +16 -17
  101. package/dist/contexts/RPDocumentContext.js +13 -14
  102. package/dist/contexts/RenderQueueProvider.js +5 -6
  103. package/dist/contexts/RotationContext.js +8 -9
  104. package/dist/contexts/SearchContext.js +5 -6
  105. package/dist/contexts/ThumbnailsContext.js +4 -5
  106. package/dist/contexts/ZoomContext.js +5 -6
  107. package/dist/floating-ui.react-dom-5ec29bd6.js +1327 -0
  108. package/dist/index-61f59539.js +1198 -0
  109. package/dist/{index-ada501c4.js → index-655864a7.js} +1 -1
  110. package/dist/{index-113053cf.js → index-c0faa594.js} +2 -2
  111. package/dist/{index-23911b43.js → index-e3ee9457.js} +6 -6
  112. package/dist/main.js +117 -115
  113. package/dist/polyfills.js +8055 -0
  114. package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
  115. package/dist/types/contexts/LayoutDropFileZoneContext.d.ts +9 -0
  116. package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
  117. package/dist/types/contexts/RenderQueueProvider.d.ts +1 -1
  118. package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
  119. package/dist/types/main.d.ts +1 -1
  120. package/dist/types/utils/annotations.d.ts +2 -2
  121. package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
  122. package/dist/types/utils/highlight.d.ts +5 -5
  123. package/dist/types/utils/hooks/useDropFileZone.d.ts +5 -0
  124. package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
  125. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
  126. package/dist/types/utils/hooks/useLoadWorker.d.ts +1 -5
  127. package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
  128. package/dist/types/utils/link_service.d.ts +3 -2
  129. package/dist/types/utils/renderPage.d.ts +2 -2
  130. package/dist/types/utils/types.d.ts +8 -5
  131. package/dist/utils/hooks/useDropFileZone.js +12 -0
  132. package/dist/utils/hooks/useFileDownload.js +5 -6
  133. package/dist/utils/hooks/useLicense.js +1 -1
  134. package/dist/utils/hooks/useLoadPdf.js +70 -95
  135. package/dist/utils/hooks/useLoadWorker.js +14 -4
  136. package/dist/utils/hooks/usePageRotateContext.js +7 -8
  137. package/dist/utils/hooks/usePaginate.js +3 -4
  138. package/dist/utils/hooks/usePinch.js +10 -11
  139. package/dist/utils/hooks/usePresentPage.js +3 -4
  140. package/dist/utils/hooks/usePrint.js +55 -54
  141. package/dist/utils/hooks/useRotate.js +3 -4
  142. package/dist/utils/hooks/useScrollToPage.js +3 -4
  143. package/dist/utils/hooks/useSearch.js +15 -16
  144. package/dist/utils/hooks/useThumbnail.js +17 -18
  145. package/dist/utils/hooks/useVirtualReactWindow.js +3 -4
  146. package/dist/utils/link_service.js +19 -18
  147. package/dist/utils/renderPage.js +1 -1
  148. package/package.json +13 -4
  149. package/dist/index-535ad364.js +0 -983
  150. package/dist/index-d0f0aa9a.js +0 -1542
@@ -1,10 +1,10 @@
1
1
  import { FC } from 'react';
2
- import { Viewport } from '@pdf-viewer/pdfium/compat';
2
+ import { PageViewport } from 'pdfjs-dist/types/web/interfaces';
3
3
  interface Props {
4
4
  pageNumber: number;
5
5
  loading: boolean;
6
6
  isFocused: boolean;
7
- viewport: Viewport;
7
+ viewport: PageViewport;
8
8
  defaultRotation: number;
9
9
  }
10
10
  export declare const Thumbnail: FC<Props>;
@@ -0,0 +1,9 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ interface LayoutDropFileZoneProviderProps extends PropsWithChildren {
3
+ value: LayoutDropFileZoneValue;
4
+ }
5
+ type LayoutDropFileZoneValue = boolean | React.ReactNode | React.ComponentType;
6
+ export declare const LayoutDropFileZoneContext: import('react').Context<LayoutDropFileZoneValue>;
7
+ export declare const useLayoutDropFileZoneContext: () => LayoutDropFileZoneValue;
8
+ export declare const LayoutDropFileZoneProvider: FC<LayoutDropFileZoneProviderProps>;
9
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  import { DocumentContextType, RPSrc, CharacterMap, LoadPDFOptions } from '../utils/types';
3
- import { PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
3
+ import { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
4
4
  declare const DocumentContext: React.Context<DocumentContextType>;
5
5
  interface Props extends PropsWithChildren, LoadPDFOptions {
6
6
  src?: RPSrc;
@@ -1,6 +1,6 @@
1
1
  import { Queue } from '../utils/Queue';
2
2
  import { FC } from 'react';
3
- import { PDFPageProxy } from '@pdf-viewer/pdfium/compat';
3
+ import { PDFPageProxy } from 'pdfjs-dist';
4
4
  import { RenderOptions } from '../utils/types';
5
5
  interface RenderData {
6
6
  page: PDFPageProxy;
@@ -1,7 +1,7 @@
1
- import { Viewport } from '@pdf-viewer/pdfium/compat';
1
+ import { PageViewport } from 'pdfjs-dist';
2
2
  import { FC, PropsWithChildren } from 'react';
3
3
  interface CacheContext {
4
- viewports: Map<number, Viewport>;
4
+ viewports: Map<number, PageViewport>;
5
5
  pages: Map<number, any>;
6
6
  }
7
7
  export declare const RenderedPagesCacheContext: import('react').Context<CacheContext>;
@@ -21,7 +21,7 @@ export { useHighlightContext } from './contexts/HighlightContext';
21
21
  export { useFullScreenContext } from './contexts/FullScreenContext';
22
22
  export { usePageRotateContext } from './utils/hooks/usePageRotateContext';
23
23
  export { useElementPageContext } from './contexts/ElementPageContext';
24
- export { type PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
24
+ export { type PDFDocumentProxy } from 'pdfjs-dist';
25
25
  export { SearchTool } from './components/layout/toolbar/SearchTool';
26
26
  export { ThemeSwitcherTool } from './components/layout/toolbar/tools/ThemeSwitcherTool';
27
27
  export { ThumbnailTool } from './components/layout/toolbar/tools/ThumbnailTool';
@@ -1,10 +1,10 @@
1
- import { Viewport, PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
1
+ import { PageViewport, PDFDocumentProxy } from 'pdfjs-dist';
2
2
  import { Annotation, AnnotationEventPayload } from './types';
3
3
  export declare const insertDateText: (annotationLayer: HTMLDivElement | null) => void;
4
4
  export declare function bindLayerEvents(annotatedLayer: HTMLDivElement, handler: (event: Event) => void): void;
5
5
  export declare function unbindLayerEvents(annotatedLayer: HTMLDivElement, handler: (event: Event) => void): void;
6
6
  export declare function handleAnnotationLink(annotation: Annotation): void;
7
- export declare function handleAnnotationWidget(annotation: Annotation, viewport: Viewport, canvasMap: Map<string, HTMLCanvasElement>): void;
7
+ export declare function handleAnnotationWidget(annotation: Annotation, viewport: PageViewport, canvasMap: Map<string, HTMLCanvasElement>): void;
8
8
  /**
9
9
  * Fixes tabindex values greater than 0 in annotation layer elements
10
10
  * WCAG 2.1 requires tabindex to be 0, -1, or not set (for natural tab order)
@@ -1,5 +1,5 @@
1
- import { PDFPageProxy } from '@pdf-viewer/pdfium/compat';
1
+ import { PDFPageProxy } from 'pdfjs-dist/types/web/interfaces';
2
2
  export declare const getThumbnailViewport: (page: PDFPageProxy, rotation?: number) => {
3
3
  scale: number;
4
- thumbnailViewport: import('@pdf-viewer/pdfium/compat').Viewport;
4
+ thumbnailViewport: import('pdfjs-dist/types/src/display/display_utils').PageViewport;
5
5
  };
@@ -1,14 +1,14 @@
1
- import { TextContentCompat } from '@pdf-viewer/pdfium/compat';
1
+ import { TextContent } from 'pdfjs-dist/types/src/display/text_layer';
2
2
  import { SearchOptions, Match, MatchHighlight } from './types';
3
- export declare function findMatches(queries: (string | RegExp)[], textContent: TextContentCompat, pageIndex: number, options: SearchOptions): Match[];
3
+ export declare function findMatches(queries: (string | RegExp)[], textContent: TextContent, pageIndex: number, options: SearchOptions): Match[];
4
4
  export declare function isMatchEntireWord(content: string, startIdx: number, length: number): boolean;
5
- export declare function highlightMatches(matches: Match[], textContent: TextContentCompat, textDivs: HTMLElement[]): {
5
+ export declare function highlightMatches(matches: Match[], textContent: TextContent, textDivs: HTMLElement[]): {
6
6
  element: HTMLElement;
7
7
  index: number;
8
8
  }[];
9
- export declare function resetDivs(textContent: TextContentCompat, textDivs: HTMLElement[]): void;
9
+ export declare function resetDivs(textContent: TextContent, textDivs: HTMLElement[]): void;
10
10
  export declare function getHighlightOptionsWithDefaults(options?: SearchOptions): SearchOptions;
11
- export declare function highlightMultipleColorMatches(matches: MatchHighlight[], textContent: TextContentCompat, textDivs: HTMLElement[]): {
11
+ export declare function highlightMultipleColorMatches(matches: MatchHighlight[], textContent: TextContent, textDivs: HTMLElement[]): {
12
12
  element: HTMLElement;
13
13
  index: number;
14
14
  }[];
@@ -0,0 +1,5 @@
1
+ export declare const useDropFileZone: () => {
2
+ DropFileZoneLayout: import('react').ReactNode | import('react').ComponentType<{}>;
3
+ DropFileZoneTool: import('react').ReactNode | import('react').ComponentType<{}>;
4
+ DropFileZoneToolbar: import('react').ReactNode | import('react').ComponentType<{}>;
5
+ };
@@ -1,4 +1,4 @@
1
- import { PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
1
+ import { PDFDocumentProxy } from 'pdfjs-dist';
2
2
  import { MatchHighlight, TextHighlight } from '../types';
3
3
  interface UseHighlight {
4
4
  highlight: (value: TextHighlight[]) => Promise<void>;
@@ -1,6 +1,6 @@
1
- import { PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
1
+ import { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api.js';
2
2
  import { PdfPage, RPSrc, CharacterMap, LoadPDFOptions, ErrorType } from '../types';
3
- export declare const useLoadPdf: (src?: RPSrc, _characterMap?: CharacterMap, options?: LoadPDFOptions) => {
3
+ export declare const useLoadPdf: (src?: RPSrc, characterMap?: CharacterMap, options?: LoadPDFOptions) => {
4
4
  pdf: PDFDocumentProxy | undefined;
5
5
  pages: Map<number, PdfPage>;
6
6
  loading: boolean;
@@ -1,7 +1,3 @@
1
- /**
2
- * @deprecated No longer needed — PDFium uses WASM directly without a web worker.
3
- * Kept for backward compatibility in case external code references it.
4
- */
5
- export declare const useLoadWorker: (_workerUrl?: string) => {
1
+ export declare const useLoadWorker: (workerUrl?: string) => {
6
2
  workerUrlAdded: boolean;
7
3
  };
@@ -1,4 +1,4 @@
1
- import { PDFDocumentProxy } from '@pdf-viewer/pdfium/compat';
1
+ import { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
2
2
  import { PdfProperties, PDFSrc } from '../types';
3
3
  type CMapSource = {
4
4
  url: string;
@@ -1,5 +1,6 @@
1
- import { PDFDocumentProxy, LinkService } from '@pdf-viewer/pdfium/compat';
2
- declare class SimpleLinkService implements LinkService {
1
+ import { PDFDocumentProxy } from 'pdfjs-dist';
2
+ import { IPDFLinkService } from 'pdfjs-dist/types/web/interfaces';
3
+ declare class SimpleLinkService implements IPDFLinkService {
3
4
  externalLinkEnabled: boolean;
4
5
  pdfDocument: PDFDocumentProxy | undefined;
5
6
  constructor(pdfDocument: PDFDocumentProxy, goToPage: (page: number) => void);
@@ -1,3 +1,3 @@
1
- import { PDFPageProxy, RenderTask } from '@pdf-viewer/pdfium/compat';
1
+ import { PDFPageProxy } from 'pdfjs-dist/types/web/interfaces';
2
2
  import { RenderOptions } from './types';
3
- export declare const renderPage: (page: PDFPageProxy, canvasElem: HTMLCanvasElement, options?: RenderOptions) => RenderTask;
3
+ export declare const renderPage: (page: PDFPageProxy, canvasElem: HTMLCanvasElement, options?: RenderOptions) => import('pdfjs-dist/types/src/display/api').RenderTask;
@@ -1,4 +1,6 @@
1
- import { PDFDocumentProxy, PDFPageProxy, Viewport } from '@pdf-viewer/pdfium/compat';
1
+ import { PDFPageProxy } from 'pdfjs-dist';
2
+ import { DocumentInitParameters, PDFDataRangeTransport, PDFDocumentProxy, TypedArray } from 'pdfjs-dist/types/src/display/api';
3
+ import { PageViewport } from 'pdfjs-dist/types/web/interfaces';
2
4
  import { Dispatch, FC, PropsWithChildren, SetStateAction } from 'react';
3
5
  export interface DocumentContextType {
4
6
  pdf?: PDFDocumentProxy;
@@ -251,7 +253,7 @@ export type DecryptedLicense = {
251
253
  };
252
254
  export interface PdfPage {
253
255
  page: PDFPageProxy;
254
- thumbnailViewport: Viewport;
256
+ thumbnailViewport: PageViewport;
255
257
  thumbnailScale: number;
256
258
  defaultRotation: number;
257
259
  }
@@ -288,7 +290,7 @@ export interface ThumbnailRenderedList {
288
290
  loading: boolean;
289
291
  page: PDFPageProxy;
290
292
  thumbnailSrc?: string;
291
- viewport: Viewport;
293
+ viewport: PageViewport;
292
294
  scale: number;
293
295
  defaultRotation: number;
294
296
  }
@@ -297,8 +299,8 @@ export declare enum ViewMode {
297
299
  DUAL_PAGE = "Dual",
298
300
  DUAL_PAGE_WITH_COVER = "DualWithCover"
299
301
  }
300
- export type PDFSrc = string | URL | ArrayBuffer | Uint8Array | undefined | null;
301
- export type RPSrc = PDFSrc;
302
+ export type PDFSrc = string | URL | TypedArray | PDFDataRangeTransport | DocumentInitParameters | undefined | null;
303
+ export type RPSrc = Omit<PDFSrc, 'DocumentInitParameters' | 'PDFDataRangeTransport'>;
302
304
  export interface FullScreenToolProps {
303
305
  isFullScreen: boolean;
304
306
  toggleFullScreen: () => void;
@@ -520,6 +522,7 @@ export interface RPDefaultLayoutProps extends PropsWithChildren, ViewportProps {
520
522
  cleanupOnLoaded?: () => void;
521
523
  }
522
524
  export interface RPLayoutProps extends PropsWithChildren, ViewportProps {
525
+ dropFileZone?: boolean | React.ReactNode | React.ComponentType;
523
526
  toolbar?: boolean | Partial<ToolbarProps>;
524
527
  style?: React.CSSProperties;
525
528
  className?: string;
@@ -0,0 +1,12 @@
1
+ import { useLayoutDropFileZoneContext as r } from "../../contexts/LayoutDropFileZoneContext.js";
2
+ import { useToolComponentContext as n } from "../../contexts/ToolComponentContext.js";
3
+ import { useToolbarComponentContext as p } from "../../contexts/ToolbarComponentContext.js";
4
+ import "react/jsx-runtime";
5
+ import "react";
6
+ const F = () => {
7
+ const o = r(), { dropFileZone: e } = n(), { dropFileZone: t } = p();
8
+ return { DropFileZoneLayout: o, DropFileZoneTool: e, DropFileZoneToolbar: t };
9
+ };
10
+ export {
11
+ F as useDropFileZone
12
+ };
@@ -3,8 +3,7 @@ import { useCallback as a } from "react";
3
3
  import { useDownloadContext as s } from "../../contexts/DownloadContext.js";
4
4
  import "react/jsx-runtime";
5
5
  import "./useLoadPdf.js";
6
- import "@pdf-viewer/pdfium";
7
- import "@pdf-viewer/pdfium/compat";
6
+ import "pdfjs-dist";
8
7
  import "../types.js";
9
8
  import "../../de_DE-a553b162.js";
10
9
  import "../getThumbnailViewport.js";
@@ -14,10 +13,10 @@ import "../appConsole.js";
14
13
  import "./usePdfProperties.js";
15
14
  import "../convertPdfDate.js";
16
15
  import "../formatFileSize.js";
17
- const i = ".pdf", d = (o) => URL.createObjectURL(o), p = async (o) => {
16
+ const i = ".pdf", d = (o) => URL.createObjectURL(o), l = async (o) => {
18
17
  const r = await (await fetch(o)).blob();
19
18
  return d(r);
20
- }, B = () => {
19
+ }, k = () => {
21
20
  const { filename: o, pdfSrc: e } = c(), { downloadFilename: r } = s(), m = (t) => {
22
21
  const n = r || t;
23
22
  return n.endsWith(i) ? n : `${n}${i}`;
@@ -26,9 +25,9 @@ const i = ".pdf", d = (o) => URL.createObjectURL(o), p = async (o) => {
26
25
  if (!o || !e)
27
26
  throw new Error("There is no PDF source to download");
28
27
  const t = document.createElement("a");
29
- t.href = await p(e), t.download = m(o), document.body.appendChild(t), t.click(), document.body.removeChild(t);
28
+ t.href = await l(e), t.download = m(o), document.body.appendChild(t), t.click(), document.body.removeChild(t);
30
29
  }, [o, e]) };
31
30
  };
32
31
  export {
33
- B as useFileDownload
32
+ k as useFileDownload
34
33
  };
@@ -1,6 +1,6 @@
1
1
  import { useState as E, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2026-03-10T05:15:21.036Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2026-03-13T02:44:19.445Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,
@@ -1,111 +1,86 @@
1
- import { useState as h, useRef as I, useEffect as P } from "react";
2
- import { init as F } from "@pdf-viewer/pdfium";
3
- import { createDocumentProxy as N } from "@pdf-viewer/pdfium/compat";
4
- import { ErrorType as O } from "../types.js";
5
- import { getThumbnailViewport as q } from "../getThumbnailViewport.js";
6
- import { useConfigContext as v } from "../../contexts/ConfigContext.js";
1
+ import { useState as a, useRef as F, useEffect as v } from "react";
2
+ import * as U from "pdfjs-dist";
3
+ import { ErrorType as j } from "../types.js";
4
+ import { getThumbnailViewport as z } from "../getThumbnailViewport.js";
5
+ import { useConfigContext as _ } from "../../contexts/ConfigContext.js";
7
6
  import { useDocumentPasswordContext as B } from "../../contexts/DocumentPasswordContext.js";
8
7
  import "../../de_DE-a553b162.js";
9
8
  import "react/jsx-runtime";
10
9
  import "../appConsole.js";
11
- async function W(t, c) {
12
- const a = await fetch(typeof t == "string" ? t : t.href);
13
- if (!a.ok)
14
- throw new Error(`Failed to fetch PDF: ${a.status} ${a.statusText}`);
15
- const o = a.headers.get("content-length"), l = o ? parseInt(o, 10) : 0;
16
- if (!a.body || !l) {
17
- const n = await a.arrayBuffer();
18
- return c == null || c(100), n;
19
- }
20
- const y = a.body.getReader(), p = [];
21
- let m = 0;
22
- for (; ; ) {
23
- const { done: n, value: i } = await y.read();
24
- if (n)
25
- break;
26
- p.push(i), m += i.length, l && (c == null || c(Math.min(100, Math.round(m / l * 100))));
27
- }
28
- const w = new Uint8Array(m);
29
- let s = 0;
30
- for (const n of p)
31
- w.set(n, s), s += n.length;
32
- return w.buffer;
33
- }
34
- const re = (t, c, a = {}) => {
35
- const [o, l] = h(), { workerUrlAdded: y, wasmUrl: p } = v(), [m, w] = h(/* @__PURE__ */ new Map()), s = I(), [n, i] = h(0), [D, _] = h(!1), [T, M] = h(), { password: x, passwordError: V, setPasswordError: b, passwordRequired: E, setPasswordRequired: R } = B(), { onLoadError: A, onLoaded: L, onLoadProgress: S, disableAutoFetch: $, disableStream: z, rangeChunkSize: Q } = a, u = I();
36
- return P(() => {
37
- S && S(n);
38
- }, [n, S]), P(() => {
39
- if (!y || !t)
10
+ const Z = (m, s, h = {}) => {
11
+ const [n, q] = a(), { workerUrlAdded: S, wasmUrl: f } = _(), [D, T] = a(/* @__PURE__ */ new Map()), d = F(), [g, P] = a(0), [c, x] = a(!1), [N, O] = a(), { password: u, passwordError: A, setPasswordError: p, passwordRequired: w, setPasswordRequired: E } = B(), { onLoadError: i, onLoaded: b, onLoadProgress: R, disableAutoFetch: C, disableStream: V, rangeChunkSize: I } = h;
12
+ return v(() => {
13
+ R && R(g);
14
+ }, [g, R]), v(() => {
15
+ if (!S || !m)
40
16
  return;
41
- i(0), s.current = Date.now();
42
- const f = s.current;
43
- let d = !1;
44
- return (async () => {
45
- try {
46
- _(!0);
47
- let e;
48
- if (t instanceof ArrayBuffer)
49
- e = t, i(100);
50
- else if (t instanceof Uint8Array)
51
- e = t.buffer, i(100);
52
- else if (typeof t == "string" || t instanceof URL)
53
- e = await W(t, (U) => {
54
- f === s.current && i(U);
55
- });
56
- else
57
- throw new Error("Unsupported PDF source type");
58
- if (d || f !== s.current || ((!u.current || u.current.isDestroyed) && (u.current = await F({ wasmUrl: p })), d || f !== s.current))
59
- return;
60
- const r = u.current.openDocument(e, x || void 0), g = N(r, e);
61
- f === s.current && (l(g), i(100)), L && L(g), R(!1), b("");
62
- } catch (e) {
63
- if (d)
64
- return;
65
- const r = e;
66
- r.code === "PASSWORD_REQUIRED" ? (R(!0), b(r.message || "Password required")) : r.code === "INVALID_PASSWORD" ? (R(!0), b("Incorrect password")) : (M(O.NOT_SUPPORTED), A && A(e));
67
- } finally {
68
- d || _(!1);
69
- }
70
- })(), () => {
71
- d = !0;
17
+ P(0), d.current = Date.now();
18
+ const r = d.current, y = {
19
+ url: m,
20
+ cMapPacked: (s == null ? void 0 : s.isCompressed) ?? !0,
21
+ ...(s == null ? void 0 : s.url) && { cMapUrl: s.url },
22
+ ...u && { password: u },
23
+ ...C !== void 0 && { disableAutoFetch: C },
24
+ ...V !== void 0 && { disableStream: V },
25
+ ...I !== void 0 && { rangeChunkSize: I },
26
+ ...f && { wasmUrl: f },
27
+ verbosity: U.VerbosityLevel.ERRORS
72
28
  };
73
- }, [t, y, p, x, A, L]), P(() => {
74
- if (E)
29
+ try {
30
+ const e = U.getDocument(y);
31
+ e.onProgress = (o) => {
32
+ if (r === d.current) {
33
+ const { loaded: L, total: l } = o, k = l ? Math.min(100, Math.round(L / l * 100)) : 0;
34
+ P(k);
35
+ }
36
+ }, x(!0);
37
+ const t = e.promise.then((o) => (r === d.current && (q(o), P(100)), b && b(o), E(!1), p(""), o)).catch((o) => {
38
+ o instanceof Error && o.name === "PasswordException" ? (E(!0), p(o.message || "Password required")) : o instanceof Error && o.name === "InvalidPDFException" && u ? (E(!0), p("Incorrect password")) : i && i(o);
39
+ }).finally(() => {
40
+ x(!1);
41
+ });
42
+ return () => {
43
+ t.finally(() => {
44
+ e.destroy();
45
+ });
46
+ };
47
+ } catch (e) {
48
+ O(j.NOT_SUPPORTED), i && i(e);
49
+ }
50
+ }, [m, S, f, u, i, b]), v(() => {
51
+ if (w)
75
52
  return;
76
- const f = /* @__PURE__ */ new Map();
77
- if (!o || D) {
78
- w(f);
53
+ const r = /* @__PURE__ */ new Map();
54
+ if (!n || c) {
55
+ T(r);
79
56
  return;
80
57
  }
81
- const d = o.numPages, k = [];
82
- for (let e = 1; e <= d; e++) {
83
- const r = o.getPage(e);
84
- k.push(r);
58
+ const y = n.numPages, e = [];
59
+ for (let t = 1; t <= y; t++) {
60
+ const o = n.getPage(t);
61
+ e.push(o);
85
62
  }
86
- Promise.all(k).then((e) => {
87
- e.map((r) => {
88
- const { thumbnailViewport: g, scale: U } = q(r), C = r.getViewport();
89
- f.set(r.pageNumber, {
90
- page: r,
91
- thumbnailViewport: g,
92
- thumbnailScale: U,
93
- defaultRotation: C.rotation
63
+ Promise.all(e).then((t) => {
64
+ t.map((o) => {
65
+ const { thumbnailViewport: L, scale: l } = z(o), k = o.getViewport();
66
+ r.set(o.pageNumber, {
67
+ page: o,
68
+ thumbnailViewport: L,
69
+ thumbnailScale: l,
70
+ defaultRotation: k.rotation
94
71
  });
95
- }), w(f);
72
+ }), T(r);
96
73
  });
97
- }, [o, D, E]), P(() => () => {
98
- o && o.destroy(), u.current && !u.current.isDestroyed && u.current.destroy();
99
- }, []), {
100
- pdf: o,
101
- pages: m,
102
- loading: D,
103
- error: T,
104
- loadingProgress: n,
105
- passwordRequired: E,
106
- passwordError: V
74
+ }, [n, c, w]), {
75
+ pdf: n,
76
+ pages: D,
77
+ loading: c,
78
+ error: N,
79
+ loadingProgress: g,
80
+ passwordRequired: w,
81
+ passwordError: A
107
82
  };
108
83
  };
109
84
  export {
110
- re as useLoadPdf
85
+ Z as useLoadPdf
111
86
  };