pdf-tsx 0.1.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
  4. package/dist/cjs/components/PDFSidebar.cjs +1 -0
  5. package/dist/cjs/components/PDFSidebar.module.cjs +1 -0
  6. package/dist/cjs/components/PDFViewer.cjs +1 -0
  7. package/dist/cjs/components/PDFViewer.module.cjs +1 -0
  8. package/dist/cjs/components/features/PDFAnnotations.cjs +1 -0
  9. package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -0
  10. package/dist/cjs/components/features/PDFChangeFile.cjs +1 -0
  11. package/dist/cjs/components/features/PDFDownloadButton.cjs +1 -0
  12. package/dist/cjs/components/features/PDFNavigation.cjs +1 -0
  13. package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -0
  14. package/dist/cjs/components/features/PDFOutline.cjs +1 -0
  15. package/dist/cjs/components/features/PDFOutline.module.cjs +1 -0
  16. package/dist/cjs/components/features/PDFPageFit.cjs +1 -0
  17. package/dist/cjs/components/features/PDFPrintButton.cjs +1 -0
  18. package/dist/cjs/components/features/PDFRotationControl.cjs +1 -0
  19. package/dist/cjs/components/features/PDFSearch.cjs +1 -0
  20. package/dist/cjs/components/features/PDFSearch.module.cjs +1 -0
  21. package/dist/cjs/components/features/PDFSignatures.cjs +1 -0
  22. package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -0
  23. package/dist/cjs/components/features/PDFThemeToggle.cjs +1 -0
  24. package/dist/cjs/components/features/PDFThumbnails.cjs +1 -0
  25. package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -0
  26. package/dist/cjs/components/features/PDFZoomControls.cjs +1 -0
  27. package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -0
  28. package/dist/cjs/components/ui/ToolbarButton.cjs +1 -0
  29. package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -0
  30. package/dist/cjs/components/ui/icons.cjs +1 -0
  31. package/dist/cjs/context/PDFViewerContext.cjs +1 -0
  32. package/dist/cjs/context/ThemeContext.cjs +1 -0
  33. package/dist/cjs/hooks/useAnnotationLayer.cjs +1 -0
  34. package/dist/cjs/hooks/useAnnotations.cjs +1 -0
  35. package/dist/cjs/hooks/useKeyboardShortcuts.cjs +1 -0
  36. package/dist/cjs/hooks/useOutline.cjs +1 -0
  37. package/dist/cjs/hooks/useScrollTracking.cjs +1 -0
  38. package/dist/cjs/hooks/useSignatures.cjs +1 -0
  39. package/dist/cjs/hooks/useTextLayer.cjs +1 -0
  40. package/dist/cjs/hooks/useTextSearch.cjs +1 -0
  41. package/dist/cjs/hooks/useThumbnails.cjs +1 -0
  42. package/dist/cjs/index.cjs +1 -0
  43. package/dist/cjs/node_modules/react/cjs/react-compiler-runtime.development.cjs +5 -0
  44. package/dist/cjs/node_modules/react/cjs/react-compiler-runtime.production.cjs +1 -0
  45. package/dist/cjs/node_modules/react/compiler-runtime.cjs +1 -0
  46. package/dist/cjs/pdf-tsx.css +2 -0
  47. package/dist/cjs/theme.cjs +1 -0
  48. package/dist/cjs/utils/url.cjs +1 -0
  49. package/dist/cjs/vite.svg +1 -0
  50. package/dist/components/PDFSidebar.d.ts +11 -0
  51. package/dist/components/PDFViewer.d.ts +10 -0
  52. package/dist/components/features/PDFAnnotations.d.ts +1 -0
  53. package/dist/components/features/PDFChangeFile.d.ts +6 -0
  54. package/dist/components/features/PDFDownloadButton.d.ts +6 -0
  55. package/dist/components/features/PDFNavigation.d.ts +7 -0
  56. package/dist/components/features/PDFOutline.d.ts +1 -0
  57. package/dist/components/features/PDFPageFit.d.ts +7 -0
  58. package/dist/components/features/PDFPrintButton.d.ts +6 -0
  59. package/dist/components/features/PDFRotationControl.d.ts +6 -0
  60. package/dist/components/features/PDFSearch.d.ts +9 -0
  61. package/dist/components/features/PDFSignatures.d.ts +1 -0
  62. package/dist/components/features/PDFThemeToggle.d.ts +7 -0
  63. package/dist/components/features/PDFThumbnails.d.ts +1 -0
  64. package/dist/components/features/PDFZoomControls.d.ts +7 -0
  65. package/dist/components/ui/ToolbarButton.d.ts +6 -0
  66. package/dist/components/ui/icons.d.ts +20 -0
  67. package/dist/context/PDFViewerContext.d.ts +25 -0
  68. package/dist/context/ThemeContext.d.ts +12 -0
  69. package/dist/es/_virtual/_rolldown/runtime.js +7 -0
  70. package/dist/es/components/PDFSidebar.js +43 -0
  71. package/dist/es/components/PDFSidebar.module.js +11 -0
  72. package/dist/es/components/PDFViewer.js +263 -0
  73. package/dist/es/components/PDFViewer.module.js +16 -0
  74. package/dist/es/components/features/PDFAnnotations.js +94 -0
  75. package/dist/es/components/features/PDFAnnotations.module.js +14 -0
  76. package/dist/es/components/features/PDFChangeFile.js +36 -0
  77. package/dist/es/components/features/PDFDownloadButton.js +23 -0
  78. package/dist/es/components/features/PDFNavigation.js +71 -0
  79. package/dist/es/components/features/PDFNavigation.module.js +7 -0
  80. package/dist/es/components/features/PDFOutline.js +101 -0
  81. package/dist/es/components/features/PDFOutline.module.js +9 -0
  82. package/dist/es/components/features/PDFPageFit.js +43 -0
  83. package/dist/es/components/features/PDFPrintButton.js +26 -0
  84. package/dist/es/components/features/PDFRotationControl.js +22 -0
  85. package/dist/es/components/features/PDFSearch.js +77 -0
  86. package/dist/es/components/features/PDFSearch.module.js +8 -0
  87. package/dist/es/components/features/PDFSignatures.js +133 -0
  88. package/dist/es/components/features/PDFSignatures.module.js +18 -0
  89. package/dist/es/components/features/PDFThemeToggle.js +17 -0
  90. package/dist/es/components/features/PDFThumbnails.js +40 -0
  91. package/dist/es/components/features/PDFThumbnails.module.js +11 -0
  92. package/dist/es/components/features/PDFZoomControls.js +47 -0
  93. package/dist/es/components/features/PDFZoomControls.module.js +3 -0
  94. package/dist/es/components/ui/ToolbarButton.js +16 -0
  95. package/dist/es/components/ui/ToolbarButton.module.js +6 -0
  96. package/dist/es/components/ui/icons.js +28 -0
  97. package/dist/es/context/PDFViewerContext.js +11 -0
  98. package/dist/es/context/ThemeContext.js +43 -0
  99. package/dist/es/hooks/useAnnotationLayer.js +71 -0
  100. package/dist/es/hooks/useAnnotations.js +44 -0
  101. package/dist/es/hooks/useKeyboardShortcuts.js +54 -0
  102. package/dist/es/hooks/useOutline.js +20 -0
  103. package/dist/es/hooks/useScrollTracking.js +46 -0
  104. package/dist/es/hooks/useSignatures.js +45 -0
  105. package/dist/es/hooks/useTextLayer.js +42 -0
  106. package/dist/es/hooks/useTextSearch.js +53 -0
  107. package/dist/es/hooks/useThumbnails.js +31 -0
  108. package/dist/es/index.js +16 -0
  109. package/dist/es/node_modules/react/cjs/react-compiler-runtime.development.js +14 -0
  110. package/dist/es/node_modules/react/cjs/react-compiler-runtime.production.js +11 -0
  111. package/dist/es/node_modules/react/compiler-runtime.js +10 -0
  112. package/dist/es/pdf-tsx.css +2 -0
  113. package/dist/es/theme.js +67 -0
  114. package/dist/es/utils/url.js +11 -0
  115. package/dist/es/vite.svg +1 -0
  116. package/dist/hooks/useAnnotationLayer.d.ts +20 -0
  117. package/dist/hooks/useAnnotations.d.ts +20 -0
  118. package/dist/hooks/useKeyboardShortcuts.d.ts +11 -0
  119. package/dist/hooks/useOutline.d.ts +14 -0
  120. package/dist/hooks/useScrollTracking.d.ts +14 -0
  121. package/dist/hooks/useSignatures.d.ts +17 -0
  122. package/dist/hooks/useTextLayer.d.ts +10 -0
  123. package/dist/hooks/useTextSearch.d.ts +12 -0
  124. package/dist/hooks/useThumbnails.d.ts +9 -0
  125. package/dist/index.d.ts +15 -0
  126. package/dist/pdf-tsx.cjs.js +5 -0
  127. package/dist/pdf-tsx.css +2 -0
  128. package/dist/pdf-tsx.es.js +2637 -0
  129. package/dist/theme.d.ts +24 -0
  130. package/dist/utils/url.d.ts +1 -0
  131. package/dist/vite.svg +1 -0
  132. package/package.json +60 -0
@@ -0,0 +1 @@
1
+ var e={bg:`#18181b`,surface:`#27272a`,surfaceHover:`#3f3f46`,border:`#3f3f46`,borderLight:`#52525b`,scrollArea:`#525659`,textPrimary:`#fafafa`,textSecondary:`#a1a1aa`,textMuted:`#71717a`,textPlaceholder:`#52525b`,accent:`#3b82f6`,accentHover:`#2563eb`,accentDark:`#1d4ed8`,accentLight:`#60a5fa`,accentSubtle:`rgba(59, 130, 246, 0.15)`,panelBg:`#1f1f23`,panelBorder:`#27272a`,panelHeaderBg:`#18181b`,shadowPage:`rgba(0, 0, 0, 0.4)`},t={bg:`#f4f4f5`,surface:`#ffffff`,surfaceHover:`#f4f4f5`,border:`#e4e4e7`,borderLight:`#d4d4d8`,scrollArea:`#e4e4e7`,textPrimary:`#18181b`,textSecondary:`#52525b`,textMuted:`#71717a`,textPlaceholder:`#a1a1aa`,accent:`#3b82f6`,accentHover:`#2563eb`,accentDark:`#1d4ed8`,accentLight:`#60a5fa`,accentSubtle:`rgba(59, 130, 246, 0.1)`,panelBg:`#ffffff`,panelBorder:`#e4e4e7`,panelHeaderBg:`#fafafa`,shadowPage:`rgba(0, 0, 0, 0.12)`};function n(e){return{"--pdf-bg":e.bg,"--pdf-surface":e.surface,"--pdf-surface-hover":e.surfaceHover,"--pdf-border":e.border,"--pdf-border-light":e.borderLight,"--pdf-scroll-area":e.scrollArea,"--pdf-text-primary":e.textPrimary,"--pdf-text-secondary":e.textSecondary,"--pdf-text-muted":e.textMuted,"--pdf-text-placeholder":e.textPlaceholder,"--pdf-accent":e.accent,"--pdf-accent-hover":e.accentHover,"--pdf-accent-dark":e.accentDark,"--pdf-accent-light":e.accentLight,"--pdf-accent-subtle":e.accentSubtle,"--pdf-panel-bg":e.panelBg,"--pdf-panel-border":e.panelBorder,"--pdf-panel-header-bg":e.panelHeaderBg,"--pdf-shadow-page":e.shadowPage}}exports.darkTheme=e,exports.lightTheme=t,exports.themeToCssVars=n;
@@ -0,0 +1 @@
1
+ function e(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}exports.isSafeUrl=e;
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SidebarPanel {
3
+ icon: ReactNode;
4
+ label: string;
5
+ content: ReactNode;
6
+ }
7
+ interface PDFSidebarProps {
8
+ panels: SidebarPanel[];
9
+ }
10
+ export declare function PDFSidebar({ panels }: PDFSidebarProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ interface PDFViewerProps {
3
+ file: File;
4
+ workerSrc: string;
5
+ sidebar?: React.ReactNode;
6
+ toolbar?: React.ReactNode;
7
+ onChangeFile?: (file: File) => void;
8
+ }
9
+ declare const PDFViewer: React.FC<PDFViewerProps>;
10
+ export default PDFViewer;
@@ -0,0 +1 @@
1
+ export declare function PDFAnnotations(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ interface PDFChangeFileProps {
3
+ icon: React.ReactNode;
4
+ }
5
+ export declare function PDFChangeFile({ icon }: PDFChangeFileProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ interface PDFDownloadButtonProps {
3
+ icon: React.ReactNode;
4
+ }
5
+ export declare function PDFDownloadButton({ icon }: PDFDownloadButtonProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface PDFNavigationProps {
3
+ prevIcon: React.ReactNode;
4
+ nextIcon: React.ReactNode;
5
+ }
6
+ export declare function PDFNavigation({ prevIcon, nextIcon }: PDFNavigationProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare function PDFOutline(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface PDFPageFitProps {
3
+ fitWidthIcon: React.ReactNode;
4
+ fitPageIcon: React.ReactNode;
5
+ }
6
+ export declare function PDFPageFit({ fitWidthIcon, fitPageIcon }: PDFPageFitProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ interface PDFPrintButtonProps {
3
+ icon: React.ReactNode;
4
+ }
5
+ export declare function PDFPrintButton({ icon }: PDFPrintButtonProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ interface PDFRotationControlProps {
3
+ icon: React.ReactNode;
4
+ }
5
+ export declare function PDFRotationControl({ icon }: PDFRotationControlProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ interface PDFSearchProps {
3
+ searchIcon: React.ReactNode;
4
+ prevIcon: React.ReactNode;
5
+ nextIcon: React.ReactNode;
6
+ clearIcon: React.ReactNode;
7
+ }
8
+ export declare function PDFSearch({ searchIcon, prevIcon, nextIcon, clearIcon }: PDFSearchProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1 @@
1
+ export declare function PDFSignatures(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface PDFThemeToggleProps {
3
+ lightIcon: React.ReactNode;
4
+ darkIcon: React.ReactNode;
5
+ }
6
+ export declare function PDFThemeToggle({ lightIcon, darkIcon }: PDFThemeToggleProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare function PDFThumbnails(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface PDFZoomControlsProps {
3
+ zoomOutIcon: React.ReactNode;
4
+ zoomInIcon: React.ReactNode;
5
+ }
6
+ export declare function PDFZoomControls({ zoomOutIcon, zoomInIcon }: PDFZoomControlsProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { ButtonHTMLAttributes } from 'react';
2
+ interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
3
+ $primary?: boolean;
4
+ }
5
+ export declare function ToolbarButton({ $primary, className, ...props }: Props): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,20 @@
1
+ interface IconProps {
2
+ size?: number;
3
+ }
4
+ export declare const IconZoomIn: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const IconZoomOut: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const IconSun: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const IconMoon: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const IconChevronRight: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const IconChevronLeft: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const IconChevronDown: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const IconChevronUp: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const IconPrinter: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const IconDownload: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const IconRotateCw: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const IconFitWidth: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const IconFitPage: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const IconSearch: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const IconX: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const IconFolderPlus: ({ size }: IconProps) => import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1,25 @@
1
+ import * as pdfjsLib from "pdfjs-dist";
2
+ export interface HighlightRect {
3
+ page: number;
4
+ pdfRect: [number, number, number, number];
5
+ }
6
+ export interface PDFViewerContextValue {
7
+ pdf: pdfjsLib.PDFDocumentProxy | null;
8
+ numPages: number;
9
+ zoom: number;
10
+ setZoom: React.Dispatch<React.SetStateAction<number>>;
11
+ rotation: number;
12
+ setRotation: React.Dispatch<React.SetStateAction<number>>;
13
+ currentPage: number;
14
+ goToPage: (page: number) => void;
15
+ containerRef: React.RefObject<HTMLDivElement | null>;
16
+ canvasRefs: React.RefObject<(HTMLCanvasElement | null)[]>;
17
+ file: File;
18
+ highlight: HighlightRect | null;
19
+ setHighlight: (h: HighlightRect | null) => void;
20
+ searchMatches: HighlightRect[];
21
+ setSearchMatches: (matches: HighlightRect[]) => void;
22
+ onChangeFile?: (file: File) => void;
23
+ }
24
+ export declare const PDFViewerContext: import('react').Context<PDFViewerContextValue | null>;
25
+ export declare function usePDFViewer(): PDFViewerContextValue;
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ import { Theme } from '../theme';
3
+ interface ThemeContextValue {
4
+ isDark: boolean;
5
+ toggleTheme: () => void;
6
+ theme: Theme;
7
+ }
8
+ export declare function ThemeProvider({ children }: {
9
+ children: ReactNode;
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ export declare function useTheme(): ThemeContextValue;
12
+ export {};
@@ -0,0 +1,7 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), t = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
3
+ if (typeof require < "u") return require.apply(this, arguments);
4
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
5
+ });
6
+ //#endregion
7
+ export { e as __commonJSMin, t as __require };
@@ -0,0 +1,43 @@
1
+ import { require_compiler_runtime as e } from "../node_modules/react/compiler-runtime.js";
2
+ import t from "./PDFSidebar.module.js";
3
+ import { useState as n } from "react";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ //#region src/components/PDFSidebar.tsx
6
+ var a = e();
7
+ function o(e) {
8
+ let o = (0, a.c)(14), { panels: s } = e, [c, l] = n(null), u;
9
+ o[0] === Symbol.for("react.memo_cache_sentinel") ? (u = (e) => l((t) => t === e ? null : e), o[0] = u) : u = o[0];
10
+ let d = u, f;
11
+ if (o[1] !== c || o[2] !== s) {
12
+ let e;
13
+ o[4] === c ? e = o[5] : (e = (e, n) => /* @__PURE__ */ r("button", {
14
+ className: `${t.panelButton} ${c === n ? t.panelButtonActive : ""}`,
15
+ onClick: () => d(n),
16
+ title: e.label,
17
+ children: e.icon
18
+ }, n), o[4] = c, o[5] = e), f = s.map(e), o[1] = c, o[2] = s, o[3] = f;
19
+ } else f = o[3];
20
+ let p;
21
+ o[6] === f ? p = o[7] : (p = /* @__PURE__ */ r("div", {
22
+ className: t.buttonBar,
23
+ children: f
24
+ }), o[6] = f, o[7] = p);
25
+ let m;
26
+ o[8] !== c || o[9] !== s ? (m = c !== null && /* @__PURE__ */ i("div", {
27
+ className: t.contentPanel,
28
+ children: [/* @__PURE__ */ r("div", {
29
+ className: t.panelHeader,
30
+ children: s[c].label
31
+ }), /* @__PURE__ */ r("div", {
32
+ className: t.panelBody,
33
+ children: s[c].content
34
+ })]
35
+ }), o[8] = c, o[9] = s, o[10] = m) : m = o[10];
36
+ let h;
37
+ return o[11] !== p || o[12] !== m ? (h = /* @__PURE__ */ i("div", {
38
+ className: t.wrapper,
39
+ children: [p, m]
40
+ }), o[11] = p, o[12] = m, o[13] = h) : h = o[13], h;
41
+ }
42
+ //#endregion
43
+ export { o as PDFSidebar };
@@ -0,0 +1,11 @@
1
+ var e = {
2
+ wrapper: "_wrapper_1bxn4_1",
3
+ buttonBar: "_buttonBar_1bxn4_7",
4
+ panelButton: "_panelButton_1bxn4_17",
5
+ panelButtonActive: "_panelButtonActive_1bxn4_37",
6
+ contentPanel: "_contentPanel_1bxn4_46",
7
+ panelHeader: "_panelHeader_1bxn4_54",
8
+ panelBody: "_panelBody_1bxn4_66"
9
+ };
10
+ //#endregion
11
+ export { e as default };
@@ -0,0 +1,263 @@
1
+ import { PDFViewerContext as e } from "../context/PDFViewerContext.js";
2
+ import { useScrollTracking as t } from "../hooks/useScrollTracking.js";
3
+ import { useKeyboardShortcuts as n } from "../hooks/useKeyboardShortcuts.js";
4
+ import { useTextLayer as r } from "../hooks/useTextLayer.js";
5
+ import { isSafeUrl as i } from "../utils/url.js";
6
+ import { useAnnotationLayer as a } from "../hooks/useAnnotationLayer.js";
7
+ import { ThemeProvider as o } from "../context/ThemeContext.js";
8
+ import s from "./PDFViewer.module.js";
9
+ import { useEffect as c, useRef as l, useState as u } from "react";
10
+ import * as d from "pdfjs-dist";
11
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
+ //#region src/components/PDFViewer.tsx
13
+ var m = ({ file: m, workerSrc: h, sidebar: g, toolbar: _, onChangeFile: v }) => {
14
+ c(() => {
15
+ d.GlobalWorkerOptions.workerSrc = h;
16
+ }, [h]);
17
+ let [y, b] = u(null), [x, S] = u(0), [C, w] = u(1), [T, E] = u(0), [D, O] = u(null), [k, A] = u(null), [j, M] = u([]), [N, P] = u(/* @__PURE__ */ new Set()), [F, I] = u([]), L = l(null), R = l([]), z = l([]), { currentPage: B, goToPage: V } = t({
18
+ pdf: y,
19
+ numPages: x,
20
+ zoom: C,
21
+ rotation: T,
22
+ containerRef: L,
23
+ canvasRefs: R
24
+ });
25
+ n({
26
+ pdf: y,
27
+ currentPage: B,
28
+ numPages: x,
29
+ goToPage: V,
30
+ setZoom: w,
31
+ setRotation: E
32
+ });
33
+ let H = r({
34
+ pdf: y,
35
+ zoom: C,
36
+ rotation: T,
37
+ numPages: x,
38
+ canvasRefs: R
39
+ }), U = a({
40
+ pdf: y,
41
+ zoom: C,
42
+ rotation: T,
43
+ numPages: x,
44
+ goToPage: V
45
+ });
46
+ c(() => {
47
+ (async () => {
48
+ let e = new FileReader();
49
+ e.onload = async (e) => {
50
+ let t = new Uint8Array(e.target?.result);
51
+ try {
52
+ let e = await d.getDocument(t).promise;
53
+ b(e), S(e.numPages), O(null), A(null), P(/* @__PURE__ */ new Set()), I([]), R.current = Array(e.numPages).fill(null), z.current = Array(e.numPages).fill(null);
54
+ } catch (e) {
55
+ console.error("Errore caricamento:", e);
56
+ }
57
+ }, e.readAsArrayBuffer(m);
58
+ })();
59
+ }, [m]), c(() => {
60
+ if (!y) return;
61
+ P(/* @__PURE__ */ new Set());
62
+ let e = !1;
63
+ return (async () => {
64
+ let t = z.current.map((e) => e ? (e.cancel(), e.promise.catch(() => {})) : Promise.resolve());
65
+ if (await Promise.all(t), z.current = Array(y.numPages).fill(null), e) return;
66
+ let n = [];
67
+ for (let e = 1; e <= y.numPages; e++) {
68
+ let t = (await y.getPage(e)).getViewport({
69
+ scale: C,
70
+ rotation: T
71
+ });
72
+ n.push({
73
+ width: t.width,
74
+ height: t.height
75
+ });
76
+ }
77
+ if (!e) {
78
+ I(n);
79
+ for (let t = 1; t <= y.numPages; t++) {
80
+ if (e) return;
81
+ let n = await y.getPage(t), r = n.getViewport({
82
+ scale: C,
83
+ rotation: T
84
+ }), i = R.current[t - 1];
85
+ if (i) {
86
+ let a = i.getContext("2d");
87
+ if (a) {
88
+ i.height = r.height, i.width = r.width;
89
+ let o = n.render({
90
+ canvasContext: a,
91
+ viewport: r,
92
+ canvas: i
93
+ });
94
+ z.current[t - 1] = o;
95
+ try {
96
+ await o.promise, e || P((e) => new Set(e).add(t));
97
+ } catch (e) {
98
+ e && typeof e == "object" && "name" in e && e.name !== "RenderingCancelledException" && console.error("Render error:", e);
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ })(), () => {
105
+ e = !0, z.current.forEach((e) => e?.cancel());
106
+ };
107
+ }, [
108
+ y,
109
+ C,
110
+ T
111
+ ]);
112
+ let [W, G] = u([]);
113
+ return c(() => {
114
+ if (!y || j.length === 0) {
115
+ G([]);
116
+ return;
117
+ }
118
+ let e = !1;
119
+ return (async () => {
120
+ let t = [];
121
+ for (let n of j) {
122
+ if (e) break;
123
+ let [r, i, a, o] = (await y.getPage(n.page)).getViewport({
124
+ scale: C,
125
+ rotation: T
126
+ }).convertToViewportRectangle(n.pdfRect);
127
+ t.push({
128
+ page: n.page,
129
+ x: Math.min(r, a),
130
+ y: Math.min(i, o),
131
+ width: Math.abs(a - r),
132
+ height: Math.abs(o - i)
133
+ });
134
+ }
135
+ e || G(t);
136
+ })(), () => {
137
+ e = !0;
138
+ };
139
+ }, [
140
+ j,
141
+ C,
142
+ T,
143
+ y
144
+ ]), c(() => {
145
+ if (!D || !y) return;
146
+ let e = !1;
147
+ return (async () => {
148
+ let [t, n, r, i] = (await y.getPage(D.page)).getViewport({
149
+ scale: C,
150
+ rotation: T
151
+ }).convertToViewportRectangle(D.pdfRect);
152
+ e || A({
153
+ page: D.page,
154
+ x: Math.min(t, r),
155
+ y: Math.min(n, i),
156
+ width: Math.abs(r - t),
157
+ height: Math.abs(i - n)
158
+ });
159
+ })(), () => {
160
+ e = !0;
161
+ };
162
+ }, [
163
+ D,
164
+ C,
165
+ T,
166
+ y
167
+ ]), /* @__PURE__ */ f(o, { children: /* @__PURE__ */ f(e.Provider, {
168
+ value: {
169
+ pdf: y,
170
+ numPages: x,
171
+ zoom: C,
172
+ setZoom: w,
173
+ rotation: T,
174
+ setRotation: E,
175
+ currentPage: B,
176
+ goToPage: V,
177
+ containerRef: L,
178
+ canvasRefs: R,
179
+ file: m,
180
+ highlight: D,
181
+ setHighlight: O,
182
+ searchMatches: j,
183
+ setSearchMatches: M,
184
+ onChangeFile: v
185
+ },
186
+ children: /* @__PURE__ */ p("div", {
187
+ className: s.appLayout,
188
+ children: [g, /* @__PURE__ */ p("div", {
189
+ className: s.mainContent,
190
+ children: [_ && /* @__PURE__ */ f("div", {
191
+ className: s.toolbar,
192
+ children: _
193
+ }), /* @__PURE__ */ f("div", {
194
+ className: s.scrollContainer,
195
+ ref: L,
196
+ children: Array.from({ length: x }, (e, t) => {
197
+ let n = N.has(t + 1), r = F[t];
198
+ return /* @__PURE__ */ p("div", {
199
+ className: s.pageWrapper,
200
+ children: [
201
+ !n && r && /* @__PURE__ */ f("div", {
202
+ className: s.pageSkeleton,
203
+ style: {
204
+ width: r.width,
205
+ height: r.height
206
+ }
207
+ }),
208
+ /* @__PURE__ */ f("canvas", {
209
+ className: s.pageCanvas,
210
+ ref: (e) => {
211
+ R.current[t] = e;
212
+ },
213
+ style: { display: n ? "block" : "none" }
214
+ }),
215
+ /* @__PURE__ */ f("div", {
216
+ className: `textLayer ${s.textLayer}`,
217
+ ref: (e) => {
218
+ H.current[t] = e;
219
+ }
220
+ }),
221
+ U.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ f("a", {
222
+ className: s.linkOverlay,
223
+ href: e.url && i(e.url) ? e.url : "#",
224
+ target: "_blank",
225
+ rel: "noopener noreferrer",
226
+ style: {
227
+ left: e.x,
228
+ top: e.y,
229
+ width: e.width,
230
+ height: e.height
231
+ },
232
+ onClick: (t) => {
233
+ (!e.url || !i(e.url)) && (t.preventDefault(), e.url || e._handleClick());
234
+ }
235
+ }, t)),
236
+ W.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ f("div", {
237
+ className: s.searchMatchOverlay,
238
+ style: {
239
+ left: e.x,
240
+ top: e.y,
241
+ width: e.width,
242
+ height: e.height
243
+ }
244
+ }, t)),
245
+ D && k?.page === t + 1 && /* @__PURE__ */ f("div", {
246
+ className: s.highlightOverlay,
247
+ style: {
248
+ left: k.x,
249
+ top: k.y,
250
+ width: k.width,
251
+ height: k.height
252
+ }
253
+ })
254
+ ]
255
+ }, `${t}-${T}`);
256
+ })
257
+ })]
258
+ })]
259
+ })
260
+ }) });
261
+ };
262
+ //#endregion
263
+ export { m as default };
@@ -0,0 +1,16 @@
1
+ var e = {
2
+ appLayout: "_appLayout_1k76a_1",
3
+ mainContent: "_mainContent_1k76a_7",
4
+ toolbar: "_toolbar_1k76a_14",
5
+ scrollContainer: "_scrollContainer_1k76a_26",
6
+ pageWrapper: "_pageWrapper_1k76a_36",
7
+ pageCanvas: "_pageCanvas_1k76a_41",
8
+ textLayer: "_textLayer_1k76a_48",
9
+ pageSkeleton: "_pageSkeleton_1k76a_54",
10
+ shimmer: "_shimmer_1k76a_1",
11
+ highlightOverlay: "_highlightOverlay_1k76a_66",
12
+ linkOverlay: "_linkOverlay_1k76a_74",
13
+ searchMatchOverlay: "_searchMatchOverlay_1k76a_80"
14
+ };
15
+ //#endregion
16
+ export { e as default };
@@ -0,0 +1,94 @@
1
+ import { usePDFViewer as e } from "../../context/PDFViewerContext.js";
2
+ import { require_compiler_runtime as t } from "../../node_modules/react/compiler-runtime.js";
3
+ import { useAnnotations as n } from "../../hooks/useAnnotations.js";
4
+ import r from "./PDFAnnotations.module.js";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ //#region src/components/features/PDFAnnotations.tsx
7
+ var o = t(), s = {
8
+ Text: "Nota",
9
+ Highlight: "Evidenziazione",
10
+ Underline: "Sottolineatura",
11
+ StrikeOut: "Barrato",
12
+ FreeText: "Testo libero",
13
+ Ink: "Disegno",
14
+ Square: "Rettangolo",
15
+ Circle: "Cerchio",
16
+ Line: "Linea",
17
+ Stamp: "Timbro",
18
+ FileAttachment: "Allegato"
19
+ };
20
+ function c(e) {
21
+ return e ? `rgb(${e.r}, ${e.g}, ${e.b})` : "#d4d4d8";
22
+ }
23
+ function l(e) {
24
+ let t = (0, o.c)(22), { ann: n, onClick: l } = e, u = s[n.subtype] ?? n.subtype, d = `${r.card} ${n.rect ? r.cardClickable : ""}`, f;
25
+ t[0] === n.color ? f = t[1] : (f = c(n.color), t[0] = n.color, t[1] = f);
26
+ let p = `3px solid ${f}`, m;
27
+ t[2] === p ? m = t[3] : (m = { borderLeft: p }, t[2] = p, t[3] = m);
28
+ let h;
29
+ t[4] === u ? h = t[5] : (h = /* @__PURE__ */ i("span", {
30
+ className: r.cardLabel,
31
+ children: u
32
+ }), t[4] = u, t[5] = h);
33
+ let g;
34
+ t[6] === n.page ? g = t[7] : (g = /* @__PURE__ */ a("span", {
35
+ className: r.cardPage,
36
+ children: ["p.", n.page]
37
+ }), t[6] = n.page, t[7] = g);
38
+ let _;
39
+ t[8] !== h || t[9] !== g ? (_ = /* @__PURE__ */ a("div", {
40
+ className: r.cardHeader,
41
+ children: [h, g]
42
+ }), t[8] = h, t[9] = g, t[10] = _) : _ = t[10];
43
+ let v;
44
+ t[11] === n.title ? v = t[12] : (v = n.title && /* @__PURE__ */ i("div", {
45
+ className: r.cardAuthor,
46
+ children: n.title
47
+ }), t[11] = n.title, t[12] = v);
48
+ let y;
49
+ t[13] === n.contents ? y = t[14] : (y = n.contents && /* @__PURE__ */ i("div", {
50
+ className: r.cardContent,
51
+ children: n.contents
52
+ }), t[13] = n.contents, t[14] = y);
53
+ let b;
54
+ return t[15] !== l || t[16] !== d || t[17] !== m || t[18] !== _ || t[19] !== v || t[20] !== y ? (b = /* @__PURE__ */ a("div", {
55
+ className: d,
56
+ style: m,
57
+ onClick: l,
58
+ children: [
59
+ _,
60
+ v,
61
+ y
62
+ ]
63
+ }), t[15] = l, t[16] = d, t[17] = m, t[18] = _, t[19] = v, t[20] = y, t[21] = b) : b = t[21], b;
64
+ }
65
+ function u() {
66
+ let { pdf: t, goToPage: o, setHighlight: s } = e(), { annotations: c, loading: u } = n({ pdf: t }), d = (e) => {
67
+ o(e.page), e.rect && s({
68
+ page: e.page,
69
+ pdfRect: e.rect
70
+ });
71
+ }, f = c.reduce((e, t) => ((e[t.page] ??= []).push(t), e), {});
72
+ return /* @__PURE__ */ a("div", {
73
+ className: r.list,
74
+ children: [
75
+ u && /* @__PURE__ */ i("div", {
76
+ className: r.emptyState,
77
+ children: "Caricamento..."
78
+ }),
79
+ !u && c.length === 0 && /* @__PURE__ */ i("div", {
80
+ className: r.emptyState,
81
+ children: "Nessuna annotazione rilevata."
82
+ }),
83
+ !u && Object.entries(f).map(([e, t]) => /* @__PURE__ */ a("div", { children: [/* @__PURE__ */ a("div", {
84
+ className: r.pageHeader,
85
+ children: ["Pagina ", e]
86
+ }), t.map((e) => /* @__PURE__ */ i(l, {
87
+ ann: e,
88
+ onClick: () => d(e)
89
+ }, e.id))] }, e))
90
+ ]
91
+ });
92
+ }
93
+ //#endregion
94
+ export { u as PDFAnnotations };
@@ -0,0 +1,14 @@
1
+ var e = {
2
+ list: "_list_xo7yf_1",
3
+ emptyState: "_emptyState_xo7yf_6",
4
+ pageHeader: "_pageHeader_xo7yf_12",
5
+ card: "_card_xo7yf_23",
6
+ cardClickable: "_cardClickable_xo7yf_33",
7
+ cardHeader: "_cardHeader_xo7yf_41",
8
+ cardLabel: "_cardLabel_xo7yf_48",
9
+ cardPage: "_cardPage_xo7yf_54",
10
+ cardAuthor: "_cardAuthor_xo7yf_59",
11
+ cardContent: "_cardContent_xo7yf_65"
12
+ };
13
+ //#endregion
14
+ export { e as default };