react-pdf
Advanced tools
Comparing version 7.2.0 to 7.3.0
@@ -6,3 +6,3 @@ /** | ||
import type { EventProps } from 'make-event-props'; | ||
import type { ClassName, DocumentCallback, ExternalLinkRel, ExternalLinkTarget, File, ImageResourcesPath, NodeOrRenderer, OnDocumentLoadError, OnDocumentLoadProgress, OnDocumentLoadSuccess, OnError, OnItemClickArgs, OnPasswordCallback, Options, PasswordResponse, RenderMode } from './shared/types'; | ||
import type { ClassName, DocumentCallback, ExternalLinkRel, ExternalLinkTarget, File, ImageResourcesPath, NodeOrRenderer, OnDocumentLoadError, OnDocumentLoadProgress, OnDocumentLoadSuccess, OnError, OnItemClickArgs, OnPasswordCallback, Options, PasswordResponse, RenderMode } from './shared/types.js'; | ||
type OnItemClick = (args: OnItemClickArgs) => void; | ||
@@ -55,3 +55,3 @@ type OnPassword = (callback: OnPasswordCallback, reason: PasswordResponse) => void; | ||
rotate?: number | null | undefined; | ||
} & EventProps<false | import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined> & React.RefAttributes<unknown>>; | ||
} & EventProps<false | import("pdfjs-dist/types/src/display/api.js").PDFDocumentProxy | undefined> & React.RefAttributes<unknown>>; | ||
export default Document; |
@@ -61,13 +61,13 @@ "use strict"; | ||
const pdfjs = __importStar(require("pdfjs-dist")); | ||
const DocumentContext_1 = __importDefault(require("./DocumentContext")); | ||
const Message_1 = __importDefault(require("./Message")); | ||
const LinkService_1 = __importDefault(require("./LinkService")); | ||
const PasswordResponses_1 = __importDefault(require("./PasswordResponses")); | ||
const utils_1 = require("./shared/utils"); | ||
const useResolver_1 = __importDefault(require("./shared/hooks/useResolver")); | ||
const propTypes_1 = require("./shared/propTypes"); | ||
const DocumentContext_js_1 = __importDefault(require("./DocumentContext.js")); | ||
const Message_js_1 = __importDefault(require("./Message.js")); | ||
const LinkService_js_1 = __importDefault(require("./LinkService.js")); | ||
const PasswordResponses_js_1 = __importDefault(require("./PasswordResponses.js")); | ||
const utils_js_1 = require("./shared/utils.js"); | ||
const useResolver_js_1 = __importDefault(require("./shared/hooks/useResolver.js")); | ||
const propTypes_js_1 = require("./shared/propTypes.js"); | ||
const { PDFDataRangeTransport } = pdfjs; | ||
const defaultOnPassword = (callback, reason) => { | ||
switch (reason) { | ||
case PasswordResponses_1.default.NEED_PASSWORD: { | ||
case PasswordResponses_js_1.default.NEED_PASSWORD: { | ||
// eslint-disable-next-line no-alert | ||
@@ -78,3 +78,3 @@ const password = prompt('Enter the password to open this PDF file.'); | ||
} | ||
case PasswordResponses_1.default.INCORRECT_PASSWORD: { | ||
case PasswordResponses_js_1.default.INCORRECT_PASSWORD: { | ||
// eslint-disable-next-line no-alert | ||
@@ -90,7 +90,7 @@ const password = prompt('Invalid password. Please try again.'); | ||
var { children, className, error = 'Failed to load PDF file.', externalLinkRel, externalLinkTarget, file, inputRef, imageResourcesPath, loading = 'Loading PDF…', noData = 'No PDF file specified.', onItemClick, onLoadError: onLoadErrorProps, onLoadProgress, onLoadSuccess: onLoadSuccessProps, onPassword = defaultOnPassword, onSourceError: onSourceErrorProps, onSourceSuccess: onSourceSuccessProps, options, renderMode, rotate } = _a, otherProps = __rest(_a, ["children", "className", "error", "externalLinkRel", "externalLinkTarget", "file", "inputRef", "imageResourcesPath", "loading", "noData", "onItemClick", "onLoadError", "onLoadProgress", "onLoadSuccess", "onPassword", "onSourceError", "onSourceSuccess", "options", "renderMode", "rotate"]); | ||
const [sourceState, sourceDispatch] = (0, useResolver_1.default)(); | ||
const [sourceState, sourceDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: source, error: sourceError } = sourceState; | ||
const [pdfState, pdfDispatch] = (0, useResolver_1.default)(); | ||
const [pdfState, pdfDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: pdf, error: pdfError } = pdfState; | ||
const linkService = (0, react_1.useRef)(new LinkService_1.default()); | ||
const linkService = (0, react_1.useRef)(new LinkService_js_1.default()); | ||
const pages = (0, react_1.useRef)([]); | ||
@@ -152,7 +152,7 @@ const viewer = (0, react_1.useRef)({ | ||
if (typeof file === 'string') { | ||
if ((0, utils_1.isDataURI)(file)) { | ||
const fileByteString = (0, utils_1.dataURItoByteString)(file); | ||
if ((0, utils_js_1.isDataURI)(file)) { | ||
const fileByteString = (0, utils_js_1.dataURItoByteString)(file); | ||
return { data: fileByteString }; | ||
} | ||
(0, utils_1.displayCORSWarning)(); | ||
(0, utils_js_1.displayCORSWarning)(); | ||
return { url: file }; | ||
@@ -165,3 +165,3 @@ } | ||
// File is an ArrayBuffer | ||
if ((0, utils_1.isArrayBuffer)(file)) { | ||
if ((0, utils_js_1.isArrayBuffer)(file)) { | ||
return { data: file }; | ||
@@ -173,6 +173,6 @@ } | ||
*/ | ||
if (utils_1.isBrowser) { | ||
if (utils_js_1.isBrowser) { | ||
// File is a Blob | ||
if ((0, utils_1.isBlob)(file)) { | ||
const data = yield (0, utils_1.loadFromFile)(file); | ||
if ((0, utils_js_1.isBlob)(file)) { | ||
const data = yield (0, utils_js_1.loadFromFile)(file); | ||
return { data }; | ||
@@ -186,8 +186,8 @@ } | ||
if ('url' in file && typeof file.url === 'string') { | ||
if ((0, utils_1.isDataURI)(file.url)) { | ||
if ((0, utils_js_1.isDataURI)(file.url)) { | ||
const { url } = file, otherParams = __rest(file, ["url"]); | ||
const fileByteString = (0, utils_1.dataURItoByteString)(url); | ||
const fileByteString = (0, utils_js_1.dataURItoByteString)(url); | ||
return Object.assign({ data: fileByteString }, otherParams); | ||
} | ||
(0, utils_1.displayCORSWarning)(); | ||
(0, utils_js_1.displayCORSWarning)(); | ||
} | ||
@@ -206,3 +206,3 @@ return file; | ||
return () => { | ||
(0, utils_1.cancelRunningTask)(cancellable); | ||
(0, utils_js_1.cancelRunningTask)(cancellable); | ||
}; | ||
@@ -323,13 +323,13 @@ }, [findDocumentSource, sourceDispatch]); | ||
function renderChildren() { | ||
return react_1.default.createElement(DocumentContext_1.default.Provider, { value: childContext }, children); | ||
return react_1.default.createElement(DocumentContext_js_1.default.Provider, { value: childContext }, children); | ||
} | ||
function renderContent() { | ||
if (!file) { | ||
return react_1.default.createElement(Message_1.default, { type: "no-data" }, typeof noData === 'function' ? noData() : noData); | ||
return react_1.default.createElement(Message_js_1.default, { type: "no-data" }, typeof noData === 'function' ? noData() : noData); | ||
} | ||
if (pdf === undefined || pdf === null) { | ||
return (react_1.default.createElement(Message_1.default, { type: "loading" }, typeof loading === 'function' ? loading() : loading)); | ||
return (react_1.default.createElement(Message_js_1.default, { type: "loading" }, typeof loading === 'function' ? loading() : loading)); | ||
} | ||
if (pdf === false) { | ||
return react_1.default.createElement(Message_1.default, { type: "error" }, typeof error === 'function' ? error() : error); | ||
return react_1.default.createElement(Message_js_1.default, { type: "error" }, typeof error === 'function' ? error() : error); | ||
} | ||
@@ -343,3 +343,3 @@ return renderChildren(); | ||
const isFunctionOrNode = prop_types_1.default.oneOfType([prop_types_1.default.func, prop_types_1.default.node]); | ||
Document.propTypes = Object.assign(Object.assign({}, propTypes_1.eventProps), { children: prop_types_1.default.node, className: propTypes_1.isClassName, error: isFunctionOrNode, externalLinkRel: prop_types_1.default.string, externalLinkTarget: prop_types_1.default.oneOf(['_self', '_blank', '_parent', '_top']), file: propTypes_1.isFile, imageResourcesPath: prop_types_1.default.string, inputRef: propTypes_1.isRef, loading: isFunctionOrNode, noData: isFunctionOrNode, onItemClick: prop_types_1.default.func, onLoadError: prop_types_1.default.func, onLoadProgress: prop_types_1.default.func, onLoadSuccess: prop_types_1.default.func, onPassword: prop_types_1.default.func, onSourceError: prop_types_1.default.func, onSourceSuccess: prop_types_1.default.func, options: prop_types_1.default.shape({ | ||
Document.propTypes = Object.assign(Object.assign({}, propTypes_js_1.eventProps), { children: prop_types_1.default.node, className: propTypes_js_1.isClassName, error: isFunctionOrNode, externalLinkRel: prop_types_1.default.string, externalLinkTarget: prop_types_1.default.oneOf(['_self', '_blank', '_parent', '_top']), file: propTypes_js_1.isFile, imageResourcesPath: prop_types_1.default.string, inputRef: propTypes_js_1.isRef, loading: isFunctionOrNode, noData: isFunctionOrNode, onItemClick: prop_types_1.default.func, onLoadError: prop_types_1.default.func, onLoadProgress: prop_types_1.default.func, onLoadSuccess: prop_types_1.default.func, onPassword: prop_types_1.default.func, onSourceError: prop_types_1.default.func, onSourceSuccess: prop_types_1.default.func, options: prop_types_1.default.shape({ | ||
canvasFactory: prop_types_1.default.any, | ||
@@ -346,0 +346,0 @@ canvasMaxAreaInBytes: prop_types_1.default.number, |
/// <reference types="react" /> | ||
import type { DocumentContextType } from './shared/types'; | ||
import type { DocumentContextType } from './shared/types.js'; | ||
declare const _default: import("react").Context<DocumentContextType>; | ||
export default _default; |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
export type { DocumentProps } from './Document'; | ||
export type { OutlineProps } from './Outline'; | ||
export type { PageProps } from './Page'; | ||
export type { ThumbnailProps } from './Thumbnail'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
export type { DocumentProps } from './Document.js'; | ||
export type { OutlineProps } from './Outline.js'; | ||
export type { PageProps } from './Page.js'; | ||
export type { ThumbnailProps } from './Thumbnail.js'; | ||
export { pdfjs, Document, Outline, Page, Thumbnail, useDocumentContext, useOutlineContext, usePageContext, }; |
@@ -32,18 +32,18 @@ "use strict"; | ||
exports.pdfjs = pdfjs; | ||
const Document_1 = __importDefault(require("./Document")); | ||
exports.Document = Document_1.default; | ||
const Outline_1 = __importDefault(require("./Outline")); | ||
exports.Outline = Outline_1.default; | ||
const Page_1 = __importDefault(require("./Page")); | ||
exports.Page = Page_1.default; | ||
const Thumbnail_1 = __importDefault(require("./Thumbnail")); | ||
exports.Thumbnail = Thumbnail_1.default; | ||
const useDocumentContext_1 = __importDefault(require("./shared/hooks/useDocumentContext")); | ||
exports.useDocumentContext = useDocumentContext_1.default; | ||
const useOutlineContext_1 = __importDefault(require("./shared/hooks/useOutlineContext")); | ||
exports.useOutlineContext = useOutlineContext_1.default; | ||
const usePageContext_1 = __importDefault(require("./shared/hooks/usePageContext")); | ||
exports.usePageContext = usePageContext_1.default; | ||
const utils_1 = require("./shared/utils"); | ||
(0, utils_1.displayWorkerWarning)(); | ||
const Document_js_1 = __importDefault(require("./Document.js")); | ||
exports.Document = Document_js_1.default; | ||
const Outline_js_1 = __importDefault(require("./Outline.js")); | ||
exports.Outline = Outline_js_1.default; | ||
const Page_js_1 = __importDefault(require("./Page.js")); | ||
exports.Page = Page_js_1.default; | ||
const Thumbnail_js_1 = __importDefault(require("./Thumbnail.js")); | ||
exports.Thumbnail = Thumbnail_js_1.default; | ||
const useDocumentContext_js_1 = __importDefault(require("./shared/hooks/useDocumentContext.js")); | ||
exports.useDocumentContext = useDocumentContext_js_1.default; | ||
const useOutlineContext_js_1 = __importDefault(require("./shared/hooks/useOutlineContext.js")); | ||
exports.useOutlineContext = useOutlineContext_js_1.default; | ||
const usePageContext_js_1 = __importDefault(require("./shared/hooks/usePageContext.js")); | ||
exports.usePageContext = usePageContext_js_1.default; | ||
const utils_js_1 = require("./shared/utils.js"); | ||
(0, utils_js_1.displayWorkerWarning)(); | ||
pdfjs.GlobalWorkerOptions.workerSrc = 'pdf.worker.js'; |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
export type { DocumentProps } from './Document'; | ||
export type { OutlineProps } from './Outline'; | ||
export type { PageProps } from './Page'; | ||
export type { ThumbnailProps } from './Thumbnail'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
export type { DocumentProps } from './Document.js'; | ||
export type { OutlineProps } from './Outline.js'; | ||
export type { PageProps } from './Page.js'; | ||
export type { ThumbnailProps } from './Thumbnail.js'; | ||
import './pdf.worker.entry'; | ||
export { pdfjs, Document, Outline, Page, Thumbnail, useDocumentContext, useOutlineContext, usePageContext, }; |
@@ -32,16 +32,16 @@ "use strict"; | ||
exports.pdfjs = pdfjs; | ||
const Document_1 = __importDefault(require("./Document")); | ||
exports.Document = Document_1.default; | ||
const Outline_1 = __importDefault(require("./Outline")); | ||
exports.Outline = Outline_1.default; | ||
const Page_1 = __importDefault(require("./Page")); | ||
exports.Page = Page_1.default; | ||
const Thumbnail_1 = __importDefault(require("./Thumbnail")); | ||
exports.Thumbnail = Thumbnail_1.default; | ||
const useDocumentContext_1 = __importDefault(require("./shared/hooks/useDocumentContext")); | ||
exports.useDocumentContext = useDocumentContext_1.default; | ||
const useOutlineContext_1 = __importDefault(require("./shared/hooks/useOutlineContext")); | ||
exports.useOutlineContext = useOutlineContext_1.default; | ||
const usePageContext_1 = __importDefault(require("./shared/hooks/usePageContext")); | ||
exports.usePageContext = usePageContext_1.default; | ||
const Document_js_1 = __importDefault(require("./Document.js")); | ||
exports.Document = Document_js_1.default; | ||
const Outline_js_1 = __importDefault(require("./Outline.js")); | ||
exports.Outline = Outline_js_1.default; | ||
const Page_js_1 = __importDefault(require("./Page.js")); | ||
exports.Page = Page_js_1.default; | ||
const Thumbnail_js_1 = __importDefault(require("./Thumbnail.js")); | ||
exports.Thumbnail = Thumbnail_js_1.default; | ||
const useDocumentContext_js_1 = __importDefault(require("./shared/hooks/useDocumentContext.js")); | ||
exports.useDocumentContext = useDocumentContext_js_1.default; | ||
const useOutlineContext_js_1 = __importDefault(require("./shared/hooks/useOutlineContext.js")); | ||
exports.useOutlineContext = useOutlineContext_js_1.default; | ||
const usePageContext_js_1 = __importDefault(require("./shared/hooks/usePageContext.js")); | ||
exports.usePageContext = usePageContext_js_1.default; | ||
require("./pdf.worker.entry"); |
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
import type { Dest, ExternalLinkRel, ExternalLinkTarget, ScrollPageIntoViewArgs } from './shared/types'; | ||
import type { IPDFLinkService } from 'pdfjs-dist/types/web/interfaces'; | ||
import type { Dest, ExternalLinkRel, ExternalLinkTarget, ScrollPageIntoViewArgs } from './shared/types.js'; | ||
import type { IPDFLinkService } from 'pdfjs-dist/types/web/interfaces.js'; | ||
type PDFViewer = { | ||
@@ -5,0 +5,0 @@ currentPageNumber?: number; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
type MessageProps = { | ||
children: React.ReactNode; | ||
children?: React.ReactNode; | ||
type: 'error' | 'loading' | 'no-data'; | ||
}; | ||
declare function Message({ children, type }: MessageProps): JSX.Element; | ||
declare namespace Message { | ||
var propTypes: { | ||
children: PropTypes.Requireable<PropTypes.ReactNodeLike>; | ||
type: PropTypes.Validator<string>; | ||
}; | ||
} | ||
export default Message; | ||
export default function Message({ children, type }: MessageProps): JSX.Element; | ||
export {}; |
@@ -7,3 +7,2 @@ "use strict"; | ||
const react_1 = __importDefault(require("react")); | ||
const prop_types_1 = __importDefault(require("prop-types")); | ||
function Message({ children, type }) { | ||
@@ -13,5 +12,1 @@ return react_1.default.createElement("div", { className: `react-pdf__message react-pdf__message--${type}` }, children); | ||
exports.default = Message; | ||
Message.propTypes = { | ||
children: prop_types_1.default.node, | ||
type: prop_types_1.default.oneOf(['error', 'loading', 'no-data']).isRequired, | ||
}; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
import type { EventProps } from 'make-event-props'; | ||
import type { OnItemClickArgs } from './shared/types'; | ||
import type { ClassName, OnItemClickArgs } from './shared/types.js'; | ||
type PDFOutline = Awaited<ReturnType<PDFDocumentProxy['getOutline']>>; | ||
export type OutlineProps = { | ||
className?: string; | ||
className?: ClassName; | ||
inputRef?: React.Ref<HTMLDivElement>; | ||
@@ -15,100 +14,3 @@ onItemClick?: (props: OnItemClickArgs) => void; | ||
} & EventProps<PDFOutline | null | false | undefined>; | ||
declare function Outline(props: OutlineProps): JSX.Element | null; | ||
declare namespace Outline { | ||
var propTypes: { | ||
className: PropTypes.Requireable<NonNullable<string | (string | null | undefined)[] | null | undefined>>; | ||
inputRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
onItemClick: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
pdf: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{ | ||
getDestination: PropTypes.Validator<(...args: any[]) => any>; | ||
getOutline: PropTypes.Validator<(...args: any[]) => any>; | ||
getPage: PropTypes.Validator<(...args: any[]) => any>; | ||
numPages: PropTypes.Validator<number>; | ||
}> | null | undefined>>; | ||
onCopy?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPaste?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onFocus?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onBlur?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInput?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onReset?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSubmit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInvalid?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoad?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onError?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyPress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAbort?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlayThrough?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDurationChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEmptied?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEncrypted?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEnded?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedData?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedMetadata?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPause?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlaying?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onProgress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onRateChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeked?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeking?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onStalled?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSuspend?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTimeUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onVolumeChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWaiting?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onContextMenu?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDoubleClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrag?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragExit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrop?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSelect?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onGotPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLostPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onScroll?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWheel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationIteration?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTransitionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onToggle?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
}; | ||
} | ||
declare const Outline: React.FC<OutlineProps>; | ||
export default Outline; |
@@ -48,10 +48,10 @@ "use strict"; | ||
const tiny_warning_1 = __importDefault(require("tiny-warning")); | ||
const OutlineContext_1 = __importDefault(require("./OutlineContext")); | ||
const OutlineItem_1 = __importDefault(require("./OutlineItem")); | ||
const utils_1 = require("./shared/utils"); | ||
const useDocumentContext_1 = __importDefault(require("./shared/hooks/useDocumentContext")); | ||
const useResolver_1 = __importDefault(require("./shared/hooks/useResolver")); | ||
const propTypes_1 = require("./shared/propTypes"); | ||
function Outline(props) { | ||
const documentContext = (0, useDocumentContext_1.default)(); | ||
const OutlineContext_js_1 = __importDefault(require("./OutlineContext.js")); | ||
const OutlineItem_js_1 = __importDefault(require("./OutlineItem.js")); | ||
const utils_js_1 = require("./shared/utils.js"); | ||
const useDocumentContext_js_1 = __importDefault(require("./shared/hooks/useDocumentContext.js")); | ||
const useResolver_js_1 = __importDefault(require("./shared/hooks/useResolver.js")); | ||
const propTypes_js_1 = require("./shared/propTypes.js"); | ||
const Outline = function Outline(props) { | ||
const documentContext = (0, useDocumentContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(documentContext, 'Unable to find Document context. Did you wrap <Outline /> in <Document />?'); | ||
@@ -61,3 +61,3 @@ const mergedProps = Object.assign(Object.assign({}, documentContext), props); | ||
(0, tiny_invariant_1.default)(pdf, 'Attempted to load an outline, but no document was specified.'); | ||
const [outlineState, outlineDispatch] = (0, useResolver_1.default)(); | ||
const [outlineState, outlineDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: outline, error: outlineError } = outlineState; | ||
@@ -106,3 +106,3 @@ /** | ||
}); | ||
return () => (0, utils_1.cancelRunningTask)(runningTask); | ||
return () => (0, utils_js_1.cancelRunningTask)(runningTask); | ||
} | ||
@@ -134,8 +134,8 @@ (0, react_1.useEffect)(loadOutline, [outlineDispatch, pdf]); | ||
} | ||
return (react_1.default.createElement("ul", null, outline.map((item, itemIndex) => (react_1.default.createElement(OutlineItem_1.default, { key: typeof item.dest === 'string' ? item.dest : itemIndex, item: item }))))); | ||
return (react_1.default.createElement("ul", null, outline.map((item, itemIndex) => (react_1.default.createElement(OutlineItem_js_1.default, { key: typeof item.dest === 'string' ? item.dest : itemIndex, item: item }))))); | ||
} | ||
return (react_1.default.createElement("div", Object.assign({ className: (0, clsx_1.default)('react-pdf__Outline', className), ref: inputRef }, eventProps), | ||
react_1.default.createElement(OutlineContext_1.default.Provider, { value: childContext }, renderOutline()))); | ||
} | ||
react_1.default.createElement(OutlineContext_js_1.default.Provider, { value: childContext }, renderOutline()))); | ||
}; | ||
Outline.propTypes = Object.assign(Object.assign({}, propTypes_js_1.eventProps), { className: propTypes_js_1.isClassName, inputRef: propTypes_js_1.isRef, onItemClick: prop_types_1.default.func, onLoadError: prop_types_1.default.func, onLoadSuccess: prop_types_1.default.func, pdf: propTypes_js_1.isPdf }); | ||
exports.default = Outline; | ||
Outline.propTypes = Object.assign(Object.assign({}, propTypes_1.eventProps), { className: propTypes_1.isClassName, inputRef: propTypes_1.isRef, onItemClick: prop_types_1.default.func, onLoadError: prop_types_1.default.func, onLoadSuccess: prop_types_1.default.func, pdf: propTypes_1.isPdf }); |
/// <reference types="react" /> | ||
import type { OutlineContextType } from './shared/types'; | ||
import type { OutlineContextType } from './shared/types.js'; | ||
declare const _default: import("react").Context<OutlineContextType>; | ||
export default _default; |
/// <reference types="react" /> | ||
import PropTypes from 'prop-types'; | ||
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
@@ -9,15 +8,3 @@ type PDFOutline = Awaited<ReturnType<PDFDocumentProxy['getOutline']>>; | ||
}; | ||
declare function OutlineItem(props: OutlineItemProps): JSX.Element; | ||
declare namespace OutlineItem { | ||
var propTypes: { | ||
item: PropTypes.Validator<NonNullable<PropTypes.InferProps<{ | ||
dest: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>; | ||
items: PropTypes.Requireable<(PropTypes.InferProps<{ | ||
dest: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>; | ||
title: PropTypes.Requireable<string>; | ||
}> | null | undefined)[]>; | ||
title: PropTypes.Requireable<string>; | ||
}>>>; | ||
}; | ||
} | ||
export default OutlineItem; | ||
export default function OutlineItem(props: OutlineItemProps): JSX.Element; | ||
export {}; |
@@ -27,12 +27,11 @@ "use strict"; | ||
const react_1 = __importDefault(require("react")); | ||
const prop_types_1 = __importDefault(require("prop-types")); | ||
const tiny_invariant_1 = __importDefault(require("tiny-invariant")); | ||
const Ref_1 = __importDefault(require("./Ref")); | ||
const useCachedValue_1 = __importDefault(require("./shared/hooks/useCachedValue")); | ||
const useDocumentContext_1 = __importDefault(require("./shared/hooks/useDocumentContext")); | ||
const useOutlineContext_1 = __importDefault(require("./shared/hooks/useOutlineContext")); | ||
const Ref_js_1 = __importDefault(require("./Ref.js")); | ||
const useCachedValue_js_1 = __importDefault(require("./shared/hooks/useCachedValue.js")); | ||
const useDocumentContext_js_1 = __importDefault(require("./shared/hooks/useDocumentContext.js")); | ||
const useOutlineContext_js_1 = __importDefault(require("./shared/hooks/useOutlineContext.js")); | ||
function OutlineItem(props) { | ||
const documentContext = (0, useDocumentContext_1.default)(); | ||
const documentContext = (0, useDocumentContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(documentContext, 'Unable to find Document context. Did you wrap <Outline /> in <Document />?'); | ||
const outlineContext = (0, useOutlineContext_1.default)(); | ||
const outlineContext = (0, useOutlineContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(outlineContext, 'Unable to find Outline context.'); | ||
@@ -42,3 +41,3 @@ const mergedProps = Object.assign(Object.assign(Object.assign({}, documentContext), outlineContext), props); | ||
(0, tiny_invariant_1.default)(pdf, 'Attempted to load an outline, but no document was specified.'); | ||
const getDestination = (0, useCachedValue_1.default)(() => { | ||
const getDestination = (0, useCachedValue_js_1.default)(() => { | ||
if (typeof item.dest === 'string') { | ||
@@ -49,3 +48,3 @@ return pdf.getDestination(item.dest); | ||
}); | ||
const getPageIndex = (0, useCachedValue_1.default)(() => __awaiter(this, void 0, void 0, function* () { | ||
const getPageIndex = (0, useCachedValue_js_1.default)(() => __awaiter(this, void 0, void 0, function* () { | ||
const destination = yield getDestination(); | ||
@@ -56,5 +55,5 @@ if (!destination) { | ||
const [ref] = destination; | ||
return pdf.getPageIndex(new Ref_1.default(ref)); | ||
return pdf.getPageIndex(new Ref_js_1.default(ref)); | ||
})); | ||
const getPageNumber = (0, useCachedValue_1.default)(() => __awaiter(this, void 0, void 0, function* () { | ||
const getPageNumber = (0, useCachedValue_js_1.default)(() => __awaiter(this, void 0, void 0, function* () { | ||
const pageIndex = yield getPageIndex(); | ||
@@ -90,12 +89,1 @@ return pageIndex + 1; | ||
exports.default = OutlineItem; | ||
const isDestination = prop_types_1.default.oneOfType([prop_types_1.default.string, prop_types_1.default.arrayOf(prop_types_1.default.any)]); | ||
OutlineItem.propTypes = { | ||
item: prop_types_1.default.shape({ | ||
dest: isDestination, | ||
items: prop_types_1.default.arrayOf(prop_types_1.default.shape({ | ||
dest: isDestination, | ||
title: prop_types_1.default.string, | ||
})), | ||
title: prop_types_1.default.string, | ||
}).isRequired, | ||
}; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
import type { EventProps } from 'make-event-props'; | ||
import type { CustomRenderer, CustomTextRenderer, NodeOrRenderer, OnGetAnnotationsError, OnGetAnnotationsSuccess, OnGetStructTreeError, OnGetStructTreeSuccess, OnGetTextError, OnGetTextSuccess, OnPageLoadError, OnPageLoadSuccess, OnRenderAnnotationLayerError, OnRenderAnnotationLayerSuccess, OnRenderError, OnRenderSuccess, OnRenderTextLayerError, OnRenderTextLayerSuccess, PageCallback, RenderMode } from './shared/types'; | ||
import type { ClassName, CustomRenderer, CustomTextRenderer, NodeOrRenderer, OnGetAnnotationsError, OnGetAnnotationsSuccess, OnGetStructTreeError, OnGetStructTreeSuccess, OnGetTextError, OnGetTextSuccess, OnPageLoadError, OnPageLoadSuccess, OnRenderAnnotationLayerError, OnRenderAnnotationLayerSuccess, OnRenderError, OnRenderSuccess, OnRenderTextLayerError, OnRenderTextLayerSuccess, PageCallback, RenderMode } from './shared/types.js'; | ||
export type PageProps = { | ||
@@ -12,3 +11,3 @@ _className?: string; | ||
children?: React.ReactNode; | ||
className?: string; | ||
className?: ClassName; | ||
customRenderer?: CustomRenderer; | ||
@@ -50,127 +49,3 @@ customTextRenderer?: CustomTextRenderer; | ||
} & EventProps<PageCallback | false | undefined>; | ||
declare function Page(props: PageProps): JSX.Element; | ||
declare namespace Page { | ||
var propTypes: { | ||
canvasBackground: PropTypes.Requireable<string>; | ||
canvasRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
children: PropTypes.Requireable<PropTypes.ReactNodeLike>; | ||
className: PropTypes.Requireable<NonNullable<string | (string | null | undefined)[] | null | undefined>>; | ||
customRenderer: PropTypes.Requireable<(...args: any[]) => any>; | ||
customTextRenderer: PropTypes.Requireable<(...args: any[]) => any>; | ||
devicePixelRatio: PropTypes.Requireable<number>; | ||
error: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>; | ||
height: PropTypes.Requireable<number>; | ||
imageResourcesPath: PropTypes.Requireable<string>; | ||
inputRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
loading: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>; | ||
noData: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>; | ||
onGetTextError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onGetTextSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderTextLayerError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderTextLayerSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
pageIndex: PropTypes.Validator<number>; | ||
pageNumber: PropTypes.Validator<number>; | ||
pdf: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{ | ||
getDestination: PropTypes.Validator<(...args: any[]) => any>; | ||
getOutline: PropTypes.Validator<(...args: any[]) => any>; | ||
getPage: PropTypes.Validator<(...args: any[]) => any>; | ||
numPages: PropTypes.Validator<number>; | ||
}> | null | undefined>>; | ||
renderAnnotationLayer: PropTypes.Requireable<boolean>; | ||
renderForms: PropTypes.Requireable<boolean>; | ||
renderMode: PropTypes.Requireable<string>; | ||
renderTextLayer: PropTypes.Requireable<boolean>; | ||
rotate: PropTypes.Requireable<number>; | ||
scale: PropTypes.Requireable<number>; | ||
width: PropTypes.Requireable<number>; | ||
onCopy?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPaste?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onFocus?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onBlur?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInput?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onReset?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSubmit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInvalid?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoad?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onError?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyPress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAbort?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlayThrough?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDurationChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEmptied?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEncrypted?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEnded?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedData?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedMetadata?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPause?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlaying?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onProgress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onRateChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeked?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeking?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onStalled?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSuspend?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTimeUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onVolumeChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWaiting?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onContextMenu?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDoubleClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrag?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragExit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrop?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSelect?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onGotPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLostPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onScroll?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWheel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationIteration?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTransitionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onToggle?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
}; | ||
} | ||
declare const Page: React.FC<PageProps>; | ||
export default Page; |
@@ -49,24 +49,24 @@ "use strict"; | ||
const tiny_warning_1 = __importDefault(require("tiny-warning")); | ||
const PageContext_1 = __importDefault(require("./PageContext")); | ||
const Message_1 = __importDefault(require("./Message")); | ||
const PageCanvas_1 = __importDefault(require("./Page/PageCanvas")); | ||
const PageSVG_1 = __importDefault(require("./Page/PageSVG")); | ||
const TextLayer_1 = __importDefault(require("./Page/TextLayer")); | ||
const AnnotationLayer_1 = __importDefault(require("./Page/AnnotationLayer")); | ||
const utils_1 = require("./shared/utils"); | ||
const useDocumentContext_1 = __importDefault(require("./shared/hooks/useDocumentContext")); | ||
const useResolver_1 = __importDefault(require("./shared/hooks/useResolver")); | ||
const propTypes_1 = require("./shared/propTypes"); | ||
const PageContext_js_1 = __importDefault(require("./PageContext.js")); | ||
const Message_js_1 = __importDefault(require("./Message.js")); | ||
const PageCanvas_js_1 = __importDefault(require("./Page/PageCanvas.js")); | ||
const PageSVG_js_1 = __importDefault(require("./Page/PageSVG.js")); | ||
const TextLayer_js_1 = __importDefault(require("./Page/TextLayer.js")); | ||
const AnnotationLayer_js_1 = __importDefault(require("./Page/AnnotationLayer.js")); | ||
const utils_js_1 = require("./shared/utils.js"); | ||
const useDocumentContext_js_1 = __importDefault(require("./shared/hooks/useDocumentContext.js")); | ||
const useResolver_js_1 = __importDefault(require("./shared/hooks/useResolver.js")); | ||
const propTypes_js_1 = require("./shared/propTypes.js"); | ||
const defaultScale = 1; | ||
function Page(props) { | ||
const documentContext = (0, useDocumentContext_1.default)(); | ||
const Page = function Page(props) { | ||
const documentContext = (0, useDocumentContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(documentContext, 'Unable to find Document context. Did you wrap <Page /> in <Document />?'); | ||
const mergedProps = Object.assign(Object.assign({}, documentContext), props); | ||
const { _className = 'react-pdf__Page', _enableRegisterUnregisterPage = true, canvasBackground, canvasRef, children, className, customRenderer: CustomRenderer, customTextRenderer, devicePixelRatio, error = 'Failed to load the page.', height, inputRef, loading = 'Loading page…', noData = 'No page specified.', onGetAnnotationsError: onGetAnnotationsErrorProps, onGetAnnotationsSuccess: onGetAnnotationsSuccessProps, onGetStructTreeError: onGetStructTreeErrorProps, onGetStructTreeSuccess: onGetStructTreeSuccessProps, onGetTextError: onGetTextErrorProps, onGetTextSuccess: onGetTextSuccessProps, onLoadError: onLoadErrorProps, onLoadSuccess: onLoadSuccessProps, onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps, onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps, onRenderError: onRenderErrorProps, onRenderSuccess: onRenderSuccessProps, onRenderTextLayerError: onRenderTextLayerErrorProps, onRenderTextLayerSuccess: onRenderTextLayerSuccessProps, pageIndex: pageIndexProps, pageNumber: pageNumberProps, pdf, registerPage, renderAnnotationLayer: renderAnnotationLayerProps = true, renderForms = false, renderMode = 'canvas', renderTextLayer: renderTextLayerProps = true, rotate: rotateProps, scale: scaleProps = defaultScale, unregisterPage, width } = mergedProps, otherProps = __rest(mergedProps, ["_className", "_enableRegisterUnregisterPage", "canvasBackground", "canvasRef", "children", "className", "customRenderer", "customTextRenderer", "devicePixelRatio", "error", "height", "inputRef", "loading", "noData", "onGetAnnotationsError", "onGetAnnotationsSuccess", "onGetStructTreeError", "onGetStructTreeSuccess", "onGetTextError", "onGetTextSuccess", "onLoadError", "onLoadSuccess", "onRenderAnnotationLayerError", "onRenderAnnotationLayerSuccess", "onRenderError", "onRenderSuccess", "onRenderTextLayerError", "onRenderTextLayerSuccess", "pageIndex", "pageNumber", "pdf", "registerPage", "renderAnnotationLayer", "renderForms", "renderMode", "renderTextLayer", "rotate", "scale", "unregisterPage", "width"]); | ||
const [pageState, pageDispatch] = (0, useResolver_1.default)(); | ||
const [pageState, pageDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: page, error: pageError } = pageState; | ||
const pageElement = (0, react_1.useRef)(null); | ||
(0, tiny_invariant_1.default)(pdf, 'Attempted to load a page, but no document was specified.'); | ||
const pageIndex = (0, utils_1.isProvided)(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null; | ||
const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : ((0, utils_1.isProvided)(pageIndexProps) ? pageIndexProps + 1 : null); | ||
const pageIndex = (0, utils_js_1.isProvided)(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null; | ||
const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : ((0, utils_js_1.isProvided)(pageIndexProps) ? pageIndexProps + 1 : null); | ||
const rotate = rotateProps !== null && rotateProps !== void 0 ? rotateProps : (page ? page.rotate : null); | ||
@@ -95,3 +95,3 @@ const scale = (0, react_1.useMemo)(() => { | ||
return () => { | ||
if (!(0, utils_1.isProvided)(pageIndex)) { | ||
if (!(0, utils_js_1.isProvided)(pageIndex)) { | ||
// Impossible, but TypeScript doesn't know that | ||
@@ -115,6 +115,6 @@ return; | ||
} | ||
onLoadSuccessProps((0, utils_1.makePageCallback)(page, scale)); | ||
onLoadSuccessProps((0, utils_js_1.makePageCallback)(page, scale)); | ||
} | ||
if (_enableRegisterUnregisterPage && registerPage) { | ||
if (!(0, utils_1.isProvided)(pageIndex) || !pageElement.current) { | ||
if (!(0, utils_js_1.isProvided)(pageIndex) || !pageElement.current) { | ||
// Impossible, but TypeScript doesn't know that | ||
@@ -156,3 +156,3 @@ return; | ||
}); | ||
return () => (0, utils_1.cancelRunningTask)(runningTask); | ||
return () => (0, utils_js_1.cancelRunningTask)(runningTask); | ||
} | ||
@@ -175,3 +175,3 @@ (0, react_1.useEffect)(loadPage, [pageDispatch, pdf, pageIndex, pageNumber, registerPage]); | ||
// Technically there cannot be page without pageIndex, pageNumber, rotate and scale, but TypeScript doesn't know that | ||
page && (0, utils_1.isProvided)(pageIndex) && pageNumber && (0, utils_1.isProvided)(rotate) && (0, utils_1.isProvided)(scale) | ||
page && (0, utils_js_1.isProvided)(pageIndex) && pageNumber && (0, utils_js_1.isProvided)(rotate) && (0, utils_js_1.isProvided)(scale) | ||
? { | ||
@@ -227,3 +227,3 @@ _className, | ||
]); | ||
const eventProps = (0, react_1.useMemo)(() => (0, make_event_props_1.default)(otherProps, () => page ? (scale ? (0, utils_1.makePageCallback)(page, scale) : undefined) : page), [otherProps, page, scale]); | ||
const eventProps = (0, react_1.useMemo)(() => (0, make_event_props_1.default)(otherProps, () => page ? (scale ? (0, utils_js_1.makePageCallback)(page, scale) : undefined) : page), [otherProps, page, scale]); | ||
const pageKey = `${pageIndex}@${scale}/${rotate}`; | ||
@@ -240,6 +240,6 @@ const pageKeyNoScale = `${pageIndex}/${rotate}`; | ||
case 'svg': | ||
return react_1.default.createElement(PageSVG_1.default, { key: `${pageKeyNoScale}_svg` }); | ||
return react_1.default.createElement(PageSVG_js_1.default, { key: `${pageKeyNoScale}_svg` }); | ||
case 'canvas': | ||
default: | ||
return react_1.default.createElement(PageCanvas_1.default, { key: `${pageKey}_canvas`, canvasRef: canvasRef }); | ||
return react_1.default.createElement(PageCanvas_js_1.default, { key: `${pageKey}_canvas`, canvasRef: canvasRef }); | ||
} | ||
@@ -251,3 +251,3 @@ } | ||
} | ||
return react_1.default.createElement(TextLayer_1.default, { key: `${pageKey}_text` }); | ||
return react_1.default.createElement(TextLayer_js_1.default, { key: `${pageKey}_text` }); | ||
} | ||
@@ -262,6 +262,6 @@ function renderAnnotationLayer() { | ||
*/ | ||
return react_1.default.createElement(AnnotationLayer_1.default, { key: `${pageKey}_annotations` }); | ||
return react_1.default.createElement(AnnotationLayer_js_1.default, { key: `${pageKey}_annotations` }); | ||
} | ||
function renderChildren() { | ||
return (react_1.default.createElement(PageContext_1.default.Provider, { value: childContext }, | ||
return (react_1.default.createElement(PageContext_js_1.default.Provider, { value: childContext }, | ||
renderMainLayer(), | ||
@@ -274,9 +274,9 @@ renderTextLayer(), | ||
if (!pageNumber) { | ||
return react_1.default.createElement(Message_1.default, { type: "no-data" }, typeof noData === 'function' ? noData() : noData); | ||
return react_1.default.createElement(Message_js_1.default, { type: "no-data" }, typeof noData === 'function' ? noData() : noData); | ||
} | ||
if (pdf === null || page === undefined || page === null) { | ||
return (react_1.default.createElement(Message_1.default, { type: "loading" }, typeof loading === 'function' ? loading() : loading)); | ||
return (react_1.default.createElement(Message_js_1.default, { type: "loading" }, typeof loading === 'function' ? loading() : loading)); | ||
} | ||
if (pdf === false || page === false) { | ||
return react_1.default.createElement(Message_1.default, { type: "error" }, typeof error === 'function' ? error() : error); | ||
return react_1.default.createElement(Message_js_1.default, { type: "error" }, typeof error === 'function' ? error() : error); | ||
} | ||
@@ -292,5 +292,5 @@ return renderChildren(); | ||
} }, eventProps), renderContent())); | ||
} | ||
}; | ||
const isFunctionOrNode = prop_types_1.default.oneOfType([prop_types_1.default.func, prop_types_1.default.node]); | ||
Page.propTypes = Object.assign(Object.assign({}, propTypes_js_1.eventProps), { canvasBackground: prop_types_1.default.string, canvasRef: propTypes_js_1.isRef, children: prop_types_1.default.node, className: propTypes_js_1.isClassName, customRenderer: prop_types_1.default.func, customTextRenderer: prop_types_1.default.func, devicePixelRatio: prop_types_1.default.number, error: isFunctionOrNode, height: prop_types_1.default.number, imageResourcesPath: prop_types_1.default.string, inputRef: propTypes_js_1.isRef, loading: isFunctionOrNode, noData: isFunctionOrNode, onGetTextError: prop_types_1.default.func, onGetTextSuccess: prop_types_1.default.func, onLoadError: prop_types_1.default.func, onLoadSuccess: prop_types_1.default.func, onRenderError: prop_types_1.default.func, onRenderSuccess: prop_types_1.default.func, onRenderTextLayerError: prop_types_1.default.func, onRenderTextLayerSuccess: prop_types_1.default.func, pageIndex: propTypes_js_1.isPageIndex, pageNumber: propTypes_js_1.isPageNumber, pdf: propTypes_js_1.isPdf, renderAnnotationLayer: prop_types_1.default.bool, renderForms: prop_types_1.default.bool, renderMode: propTypes_js_1.isRenderMode, renderTextLayer: prop_types_1.default.bool, rotate: propTypes_js_1.isRotate, scale: prop_types_1.default.number, width: prop_types_1.default.number }); | ||
exports.default = Page; | ||
const isFunctionOrNode = prop_types_1.default.oneOfType([prop_types_1.default.func, prop_types_1.default.node]); | ||
Page.propTypes = Object.assign(Object.assign({}, propTypes_1.eventProps), { canvasBackground: prop_types_1.default.string, canvasRef: propTypes_1.isRef, children: prop_types_1.default.node, className: propTypes_1.isClassName, customRenderer: prop_types_1.default.func, customTextRenderer: prop_types_1.default.func, devicePixelRatio: prop_types_1.default.number, error: isFunctionOrNode, height: prop_types_1.default.number, imageResourcesPath: prop_types_1.default.string, inputRef: propTypes_1.isRef, loading: isFunctionOrNode, noData: isFunctionOrNode, onGetTextError: prop_types_1.default.func, onGetTextSuccess: prop_types_1.default.func, onLoadError: prop_types_1.default.func, onLoadSuccess: prop_types_1.default.func, onRenderError: prop_types_1.default.func, onRenderSuccess: prop_types_1.default.func, onRenderTextLayerError: prop_types_1.default.func, onRenderTextLayerSuccess: prop_types_1.default.func, pageIndex: propTypes_1.isPageIndex, pageNumber: propTypes_1.isPageNumber, pdf: propTypes_1.isPdf, renderAnnotationLayer: prop_types_1.default.bool, renderForms: prop_types_1.default.bool, renderMode: propTypes_1.isRenderMode, renderTextLayer: prop_types_1.default.bool, rotate: propTypes_1.isRotate, scale: prop_types_1.default.number, width: prop_types_1.default.number }); |
@@ -36,10 +36,10 @@ "use strict"; | ||
const pdfjs = __importStar(require("pdfjs-dist")); | ||
const useDocumentContext_1 = __importDefault(require("../shared/hooks/useDocumentContext")); | ||
const usePageContext_1 = __importDefault(require("../shared/hooks/usePageContext")); | ||
const useResolver_1 = __importDefault(require("../shared/hooks/useResolver")); | ||
const utils_1 = require("../shared/utils"); | ||
const useDocumentContext_js_1 = __importDefault(require("../shared/hooks/useDocumentContext.js")); | ||
const usePageContext_js_1 = __importDefault(require("../shared/hooks/usePageContext.js")); | ||
const useResolver_js_1 = __importDefault(require("../shared/hooks/useResolver.js")); | ||
const utils_js_1 = require("../shared/utils.js"); | ||
function AnnotationLayer() { | ||
const documentContext = (0, useDocumentContext_1.default)(); | ||
const documentContext = (0, useDocumentContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(documentContext, 'Unable to find Document context. Did you wrap <Page /> in <Document />?'); | ||
const pageContext = (0, usePageContext_1.default)(); | ||
const pageContext = (0, usePageContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(pageContext, 'Unable to find Page context.'); | ||
@@ -49,3 +49,3 @@ const mergedProps = Object.assign(Object.assign({}, documentContext), pageContext); | ||
(0, tiny_invariant_1.default)(page, 'Attempted to load page annotations, but no page was specified.'); | ||
const [annotationsState, annotationsDispatch] = (0, useResolver_1.default)(); | ||
const [annotationsState, annotationsDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: annotations, error: annotationsError } = annotationsState; | ||
@@ -91,3 +91,3 @@ const layerElement = (0, react_1.useRef)(null); | ||
return () => { | ||
(0, utils_1.cancelRunningTask)(runningTask); | ||
(0, utils_js_1.cancelRunningTask)(runningTask); | ||
}; | ||
@@ -94,0 +94,0 @@ } |
@@ -5,10 +5,3 @@ import React from 'react'; | ||
}; | ||
declare function PageCanvas(props: PageCanvasProps): JSX.Element; | ||
declare namespace PageCanvas { | ||
var propTypes: { | ||
canvasRef: import("prop-types").Requireable<NonNullable<((...args: any[]) => any) | Required<import("prop-types").InferProps<{ | ||
current: import("prop-types").Requireable<any>; | ||
}>> | null | undefined>>; | ||
}; | ||
} | ||
export default PageCanvas; | ||
export default function PageCanvas(props: PageCanvasProps): JSX.Element; | ||
export {}; |
@@ -35,12 +35,11 @@ "use strict"; | ||
const pdfjs = __importStar(require("pdfjs-dist")); | ||
const StructTree_1 = __importDefault(require("../StructTree")); | ||
const usePageContext_1 = __importDefault(require("../shared/hooks/usePageContext")); | ||
const utils_1 = require("../shared/utils"); | ||
const propTypes_1 = require("../shared/propTypes"); | ||
const StructTree_js_1 = __importDefault(require("../StructTree.js")); | ||
const usePageContext_js_1 = __importDefault(require("../shared/hooks/usePageContext.js")); | ||
const utils_js_1 = require("../shared/utils.js"); | ||
const ANNOTATION_MODE = pdfjs.AnnotationMode; | ||
function PageCanvas(props) { | ||
const pageContext = (0, usePageContext_1.default)(); | ||
const pageContext = (0, usePageContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(pageContext, 'Unable to find Page context.'); | ||
const mergedProps = Object.assign(Object.assign({}, pageContext), props); | ||
const { _className, canvasBackground, devicePixelRatio = (0, utils_1.getDevicePixelRatio)(), onRenderError: onRenderErrorProps, onRenderSuccess: onRenderSuccessProps, page, renderForms, renderTextLayer, rotate, scale, } = mergedProps; | ||
const { _className, canvasBackground, devicePixelRatio = (0, utils_js_1.getDevicePixelRatio)(), onRenderError: onRenderErrorProps, onRenderSuccess: onRenderSuccessProps, page, renderForms, renderTextLayer, rotate, scale, } = mergedProps; | ||
const { canvasRef } = props; | ||
@@ -58,3 +57,3 @@ (0, tiny_invariant_1.default)(page, 'Attempted to render page canvas, but no page was specified.'); | ||
if (onRenderSuccessProps) { | ||
onRenderSuccessProps((0, utils_1.makePageCallback)(page, scale)); | ||
onRenderSuccessProps((0, utils_js_1.makePageCallback)(page, scale)); | ||
} | ||
@@ -66,3 +65,3 @@ } | ||
function onRenderError(error) { | ||
if ((0, utils_1.isCancelException)(error)) { | ||
if ((0, utils_js_1.isCancelException)(error)) { | ||
return; | ||
@@ -108,3 +107,3 @@ } | ||
.catch(onRenderError); | ||
return () => (0, utils_1.cancelRunningTask)(runningTask); | ||
return () => (0, utils_js_1.cancelRunningTask)(runningTask); | ||
} | ||
@@ -138,7 +137,4 @@ (0, react_1.useEffect)(drawPageOnCanvas, | ||
userSelect: 'none', | ||
} }, renderTextLayer ? react_1.default.createElement(StructTree_1.default, null) : null)); | ||
} }, renderTextLayer ? react_1.default.createElement(StructTree_js_1.default, null) : null)); | ||
} | ||
exports.default = PageCanvas; | ||
PageCanvas.propTypes = { | ||
canvasRef: propTypes_1.isRef, | ||
}; |
@@ -34,11 +34,11 @@ "use strict"; | ||
const pdfjs = __importStar(require("pdfjs-dist")); | ||
const usePageContext_1 = __importDefault(require("../shared/hooks/usePageContext")); | ||
const useResolver_1 = __importDefault(require("../shared/hooks/useResolver")); | ||
const utils_1 = require("../shared/utils"); | ||
const usePageContext_js_1 = __importDefault(require("../shared/hooks/usePageContext.js")); | ||
const useResolver_js_1 = __importDefault(require("../shared/hooks/useResolver.js")); | ||
const utils_js_1 = require("../shared/utils.js"); | ||
function PageSVG() { | ||
const pageContext = (0, usePageContext_1.default)(); | ||
const pageContext = (0, usePageContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(pageContext, 'Unable to find Page context.'); | ||
const { _className, onRenderSuccess: onRenderSuccessProps, onRenderError: onRenderErrorProps, page, rotate, scale, } = pageContext; | ||
(0, tiny_invariant_1.default)(page, 'Attempted to render page SVG, but no page was specified.'); | ||
const [svgState, svgDispatch] = (0, useResolver_1.default)(); | ||
const [svgState, svgDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: svg, error: svgError } = svgState; | ||
@@ -54,3 +54,3 @@ /** | ||
if (onRenderSuccessProps) { | ||
onRenderSuccessProps((0, utils_1.makePageCallback)(page, scale)); | ||
onRenderSuccessProps((0, utils_js_1.makePageCallback)(page, scale)); | ||
} | ||
@@ -66,3 +66,3 @@ } | ||
} | ||
if ((0, utils_1.isCancelException)(svgError)) { | ||
if ((0, utils_js_1.isCancelException)(svgError)) { | ||
return; | ||
@@ -100,3 +100,3 @@ } | ||
}); | ||
return () => (0, utils_1.cancelRunningTask)(cancellable); | ||
return () => (0, utils_js_1.cancelRunningTask)(cancellable); | ||
} | ||
@@ -103,0 +103,0 @@ (0, react_1.useEffect)(renderSVG, [page, svgDispatch, viewport]); |
@@ -36,5 +36,5 @@ "use strict"; | ||
const pdfjs = __importStar(require("pdfjs-dist")); | ||
const usePageContext_1 = __importDefault(require("../shared/hooks/usePageContext")); | ||
const useResolver_1 = __importDefault(require("../shared/hooks/useResolver")); | ||
const utils_1 = require("../shared/utils"); | ||
const usePageContext_js_1 = __importDefault(require("../shared/hooks/usePageContext.js")); | ||
const useResolver_js_1 = __importDefault(require("../shared/hooks/useResolver.js")); | ||
const utils_js_1 = require("../shared/utils.js"); | ||
function isTextItem(item) { | ||
@@ -44,7 +44,7 @@ return 'str' in item; | ||
function TextLayer() { | ||
const pageContext = (0, usePageContext_1.default)(); | ||
const pageContext = (0, usePageContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(pageContext, 'Unable to find Page context.'); | ||
const { customTextRenderer, onGetTextError, onGetTextSuccess, onRenderTextLayerError, onRenderTextLayerSuccess, page, pageIndex, pageNumber, rotate, scale, } = pageContext; | ||
(0, tiny_invariant_1.default)(page, 'Attempted to load page text content, but no page was specified.'); | ||
const [textContentState, textContentDispatch] = (0, useResolver_1.default)(); | ||
const [textContentState, textContentDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: textContent, error: textContentError } = textContentState; | ||
@@ -96,3 +96,3 @@ const layerElement = (0, react_1.useRef)(null); | ||
}); | ||
return () => (0, utils_1.cancelRunningTask)(runningTask); | ||
return () => (0, utils_js_1.cancelRunningTask)(runningTask); | ||
} | ||
@@ -193,3 +193,3 @@ (0, react_1.useEffect)(loadTextContent, [page, textContentDispatch]); | ||
.catch(onRenderError); | ||
return () => (0, utils_1.cancelRunningTask)(runningTask); | ||
return () => (0, utils_js_1.cancelRunningTask)(runningTask); | ||
} | ||
@@ -196,0 +196,0 @@ (0, react_1.useLayoutEffect)(renderTextLayer, [ |
/// <reference types="react" /> | ||
import type { PageContextType } from './shared/types'; | ||
import type { PageContextType } from './shared/types.js'; | ||
declare const _default: import("react").Context<PageContextType>; | ||
export default _default; |
@@ -5,7 +5,7 @@ "use strict"; | ||
const react_1 = require("react"); | ||
const utils_1 = require("../utils"); | ||
const utils_js_1 = require("../utils.js"); | ||
function useCachedValue(getter) { | ||
const ref = (0, react_1.useRef)(); | ||
const currentValue = ref.current; | ||
if ((0, utils_1.isDefined)(currentValue)) { | ||
if ((0, utils_js_1.isDefined)(currentValue)) { | ||
return () => currentValue; | ||
@@ -12,0 +12,0 @@ } |
@@ -1,1 +0,1 @@ | ||
export default function useDocumentContext(): import("../types").DocumentContextType; | ||
export default function useDocumentContext(): import("../types.js").DocumentContextType; |
@@ -7,6 +7,6 @@ "use strict"; | ||
const react_1 = require("react"); | ||
const DocumentContext_1 = __importDefault(require("../../DocumentContext")); | ||
const DocumentContext_js_1 = __importDefault(require("../../DocumentContext.js")); | ||
function useDocumentContext() { | ||
return (0, react_1.useContext)(DocumentContext_1.default); | ||
return (0, react_1.useContext)(DocumentContext_js_1.default); | ||
} | ||
exports.default = useDocumentContext; |
@@ -1,1 +0,1 @@ | ||
export default function useOutlineContext(): import("../types").OutlineContextType; | ||
export default function useOutlineContext(): import("../types.js").OutlineContextType; |
@@ -7,6 +7,6 @@ "use strict"; | ||
const react_1 = require("react"); | ||
const OutlineContext_1 = __importDefault(require("../../OutlineContext")); | ||
const OutlineContext_js_1 = __importDefault(require("../../OutlineContext.js")); | ||
function useOutlineContext() { | ||
return (0, react_1.useContext)(OutlineContext_1.default); | ||
return (0, react_1.useContext)(OutlineContext_js_1.default); | ||
} | ||
exports.default = useOutlineContext; |
@@ -1,1 +0,1 @@ | ||
export default function usePageContext(): import("../types").PageContextType; | ||
export default function usePageContext(): import("../types.js").PageContextType; |
@@ -7,6 +7,6 @@ "use strict"; | ||
const react_1 = require("react"); | ||
const PageContext_1 = __importDefault(require("../../PageContext")); | ||
const PageContext_js_1 = __importDefault(require("../../PageContext.js")); | ||
function usePageContext() { | ||
return (0, react_1.useContext)(PageContext_1.default); | ||
return (0, react_1.useContext)(PageContext_js_1.default); | ||
} | ||
exports.default = usePageContext; |
import PropTypes from 'prop-types'; | ||
import { allEvents } from 'make-event-props'; | ||
import { PDFDataRangeTransport } from 'pdfjs-dist'; | ||
import LinkService from '../LinkService'; | ||
import LinkService from '../LinkService.js'; | ||
import type { Validator } from 'prop-types'; | ||
@@ -20,3 +20,3 @@ type AllEvents = (typeof allEvents)[number]; | ||
export declare const isLinkService: PropTypes.Requireable<LinkService>; | ||
export declare const isLinkTarget: PropTypes.Requireable<string>; | ||
export declare const isLinkTarget: PropTypes.Requireable<"_self" | "_blank" | "_parent" | "_top">; | ||
export declare const isPage: PropTypes.Requireable<PropTypes.InferProps<{ | ||
@@ -31,13 +31,8 @@ commonObjs: PropTypes.Validator<NonNullable<PropTypes.InferProps<{}>>>; | ||
export declare const isPageNumber: Validator<number>; | ||
export declare const isPdf: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{ | ||
getDestination: PropTypes.Validator<(...args: any[]) => any>; | ||
getOutline: PropTypes.Validator<(...args: any[]) => any>; | ||
getPage: PropTypes.Validator<(...args: any[]) => any>; | ||
numPages: PropTypes.Validator<number>; | ||
}> | null | undefined>>; | ||
export declare const isPdf: PropTypes.Requireable<any>; | ||
export declare const isRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
export declare const isRenderMode: PropTypes.Requireable<string>; | ||
export declare const isRotate: PropTypes.Requireable<number>; | ||
export declare const isRenderMode: PropTypes.Requireable<"none" | "custom" | "canvas" | "svg">; | ||
export declare const isRotate: PropTypes.Requireable<0 | 90 | 180 | 270>; | ||
export {}; |
@@ -10,4 +10,4 @@ "use strict"; | ||
const pdfjs_dist_1 = require("pdfjs-dist"); | ||
const utils_1 = require("./utils"); | ||
const LinkService_1 = __importDefault(require("../LinkService")); | ||
const utils_js_1 = require("./utils.js"); | ||
const LinkService_js_1 = __importDefault(require("../LinkService.js")); | ||
exports.eventProps = (() => { | ||
@@ -57,3 +57,3 @@ const result = {}; | ||
exports.isFile = prop_types_1.default.oneOfType(fileTypes); | ||
exports.isLinkService = prop_types_1.default.instanceOf(LinkService_1.default); | ||
exports.isLinkService = prop_types_1.default.instanceOf(LinkService_js_1.default); | ||
exports.isLinkTarget = prop_types_1.default.oneOf(['_self', '_blank', '_parent', '_top']); | ||
@@ -69,6 +69,6 @@ exports.isPage = prop_types_1.default.shape({ | ||
const { [propName]: pageIndex, pageNumber, pdf } = props; | ||
if (!(0, utils_1.isDefined)(pdf)) { | ||
if (!(0, utils_js_1.isDefined)(pdf)) { | ||
return null; | ||
} | ||
if ((0, utils_1.isDefined)(pageIndex)) { | ||
if ((0, utils_js_1.isDefined)(pageIndex)) { | ||
if (typeof pageIndex !== 'number') { | ||
@@ -85,3 +85,3 @@ return new Error(`\`${propName}\` of type \`${typeof pageIndex}\` supplied to \`${componentName}\`, expected \`number\`.`); | ||
} | ||
else if (!(0, utils_1.isDefined)(pageNumber)) { | ||
else if (!(0, utils_js_1.isDefined)(pageNumber)) { | ||
return new Error(`\`${propName}\` not supplied. Either pageIndex or pageNumber must be supplied to \`${componentName}\`.`); | ||
@@ -95,6 +95,6 @@ } | ||
const { [propName]: pageNumber, pageIndex, pdf } = props; | ||
if (!(0, utils_1.isDefined)(pdf)) { | ||
if (!(0, utils_js_1.isDefined)(pdf)) { | ||
return null; | ||
} | ||
if ((0, utils_1.isDefined)(pageNumber)) { | ||
if ((0, utils_js_1.isDefined)(pageNumber)) { | ||
if (typeof pageNumber !== 'number') { | ||
@@ -111,3 +111,3 @@ return new Error(`\`${propName}\` of type \`${typeof pageNumber}\` supplied to \`${componentName}\`, expected \`number\`.`); | ||
} | ||
else if (!(0, utils_1.isDefined)(pageIndex)) { | ||
else if (!(0, utils_js_1.isDefined)(pageIndex)) { | ||
return new Error(`\`${propName}\` not supplied. Either pageIndex or pageNumber must be supplied to \`${componentName}\`.`); | ||
@@ -120,9 +120,5 @@ } | ||
exports.isPdf = prop_types_1.default.oneOfType([ | ||
prop_types_1.default.shape({ | ||
getDestination: prop_types_1.default.func.isRequired, | ||
getOutline: prop_types_1.default.func.isRequired, | ||
getPage: prop_types_1.default.func.isRequired, | ||
numPages: prop_types_1.default.number.isRequired, | ||
}), | ||
prop_types_1.default.bool, | ||
// Ideally, this would be `PropTypes.instanceOf(PDFDocumentProxy)`, but it can't be imported. | ||
prop_types_1.default.any, | ||
prop_types_1.default.oneOf([false]), | ||
]); | ||
@@ -129,0 +125,0 @@ exports.isRef = prop_types_1.default.oneOfType([ |
/// <reference types="react" /> | ||
import { PDF_ROLE_TO_HTML_ROLE } from './constants'; | ||
import type { StructTreeContent, StructTreeNode } from 'pdfjs-dist/types/src/display/api'; | ||
import type { StructTreeNodeWithExtraAttributes } from './types'; | ||
import { PDF_ROLE_TO_HTML_ROLE } from './constants.js'; | ||
import type { StructTreeContent, StructTreeNode } from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { StructTreeNodeWithExtraAttributes } from './types.js'; | ||
type PdfRole = keyof typeof PDF_ROLE_TO_HTML_ROLE; | ||
@@ -6,0 +6,0 @@ type Attributes = React.HTMLAttributes<HTMLElement>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAttributes = exports.getBaseAttributes = exports.getRoleAttributes = exports.isStructTreeNodeWithOnlyContentChild = exports.isStructTreeNode = exports.isPdfRole = void 0; | ||
const constants_1 = require("./constants"); | ||
const constants_js_1 = require("./constants.js"); | ||
function isPdfRole(role) { | ||
return role in constants_1.PDF_ROLE_TO_HTML_ROLE; | ||
return role in constants_js_1.PDF_ROLE_TO_HTML_ROLE; | ||
} | ||
@@ -24,3 +24,3 @@ exports.isPdfRole = isPdfRole; | ||
const { role } = node; | ||
const matches = role.match(constants_1.HEADING_PATTERN); | ||
const matches = role.match(constants_js_1.HEADING_PATTERN); | ||
if (matches) { | ||
@@ -31,3 +31,3 @@ attributes.role = 'heading'; | ||
else if (isPdfRole(role)) { | ||
const htmlRole = constants_1.PDF_ROLE_TO_HTML_ROLE[role]; | ||
const htmlRole = constants_js_1.PDF_ROLE_TO_HTML_ROLE[role]; | ||
if (htmlRole) { | ||
@@ -34,0 +34,0 @@ attributes.role = htmlRole; |
/// <reference types="react" /> | ||
import type { PDFDataRangeTransport, PDFDocumentProxy, PDFPageProxy, PasswordResponses } from 'pdfjs-dist'; | ||
import type { BinaryData, DocumentInitParameters, RefProxy, StructTreeNode, TextContent, TextItem } from 'pdfjs-dist/types/src/display/api'; | ||
import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer'; | ||
import type LinkService from '../LinkService'; | ||
import type { BinaryData, DocumentInitParameters, RefProxy, StructTreeNode, TextContent, TextItem } from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer.js'; | ||
import type LinkService from '../LinkService.js'; | ||
type NullableObject<T extends object> = { | ||
@@ -7,0 +7,0 @@ [P in keyof T]: T[P] | null; |
import type { PDFPageProxy } from 'pdfjs-dist'; | ||
import type { PageCallback } from './types'; | ||
import type { PageCallback } from './types.js'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Checks if we're running in a browser environment. |
@@ -33,11 +33,11 @@ "use strict"; | ||
const tiny_warning_1 = __importDefault(require("tiny-warning")); | ||
const StructTreeItem_1 = __importDefault(require("./StructTreeItem")); | ||
const usePageContext_1 = __importDefault(require("./shared/hooks/usePageContext")); | ||
const useResolver_1 = __importDefault(require("./shared/hooks/useResolver")); | ||
const utils_1 = require("./shared/utils"); | ||
const StructTreeItem_js_1 = __importDefault(require("./StructTreeItem.js")); | ||
const usePageContext_js_1 = __importDefault(require("./shared/hooks/usePageContext.js")); | ||
const useResolver_js_1 = __importDefault(require("./shared/hooks/useResolver.js")); | ||
const utils_js_1 = require("./shared/utils.js"); | ||
function StructTree() { | ||
const pageContext = (0, usePageContext_1.default)(); | ||
const pageContext = (0, usePageContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(pageContext, 'Unable to find Page context.'); | ||
const { onGetStructTreeError: onGetStructTreeErrorProps, onGetStructTreeSuccess: onGetStructTreeSuccessProps, } = pageContext; | ||
const [structTreeState, structTreeDispatch] = (0, useResolver_1.default)(); | ||
const [structTreeState, structTreeDispatch] = (0, useResolver_js_1.default)(); | ||
const { value: structTree, error: structTreeError } = structTreeState; | ||
@@ -85,3 +85,3 @@ const { customTextRenderer, page } = pageContext; | ||
}); | ||
return () => (0, utils_1.cancelRunningTask)(runningTask); | ||
return () => (0, utils_js_1.cancelRunningTask)(runningTask); | ||
} | ||
@@ -105,4 +105,4 @@ (0, react_1.useEffect)(loadStructTree, [customTextRenderer, page, structTreeDispatch]); | ||
} | ||
return react_1.default.createElement(StructTreeItem_1.default, { className: "react-pdf__Page__structTree structTree", node: structTree }); | ||
return react_1.default.createElement(StructTreeItem_js_1.default, { className: "react-pdf__Page__structTree structTree", node: structTree }); | ||
} | ||
exports.default = StructTree; |
/// <reference types="react" /> | ||
import PropTypes from 'prop-types'; | ||
import type { StructTreeContent } from 'pdfjs-dist/types/src/display/api'; | ||
import type { StructTreeNodeWithExtraAttributes } from './shared/types'; | ||
import type { StructTreeContent } from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { StructTreeNodeWithExtraAttributes } from './shared/types.js'; | ||
type StructTreeItemProps = { | ||
@@ -9,14 +8,3 @@ className?: string; | ||
}; | ||
declare function StructTreeItem({ className, node }: StructTreeItemProps): JSX.Element; | ||
declare namespace StructTreeItem { | ||
var propTypes: { | ||
node: PropTypes.Validator<NonNullable<NonNullable<PropTypes.InferProps<{ | ||
children: PropTypes.Requireable<object>; | ||
role: PropTypes.Requireable<string>; | ||
}> | PropTypes.InferProps<{ | ||
id: PropTypes.Requireable<string>; | ||
type: PropTypes.Requireable<string>; | ||
}> | null | undefined>>>; | ||
}; | ||
} | ||
export default StructTreeItem; | ||
export default function StructTreeItem({ className, node }: StructTreeItemProps): JSX.Element; | ||
export {}; |
@@ -25,16 +25,12 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = __importStar(require("react")); | ||
const prop_types_1 = __importDefault(require("prop-types")); | ||
const structTreeUtils_1 = require("./shared/structTreeUtils"); | ||
const structTreeUtils_js_1 = require("./shared/structTreeUtils.js"); | ||
function StructTreeItem({ className, node }) { | ||
const attributes = (0, react_1.useMemo)(() => (0, structTreeUtils_1.getAttributes)(node), [node]); | ||
const attributes = (0, react_1.useMemo)(() => (0, structTreeUtils_js_1.getAttributes)(node), [node]); | ||
const children = (0, react_1.useMemo)(() => { | ||
if (!(0, structTreeUtils_1.isStructTreeNode)(node)) { | ||
if (!(0, structTreeUtils_js_1.isStructTreeNode)(node)) { | ||
return null; | ||
} | ||
if ((0, structTreeUtils_1.isStructTreeNodeWithOnlyContentChild)(node)) { | ||
if ((0, structTreeUtils_js_1.isStructTreeNodeWithOnlyContentChild)(node)) { | ||
return null; | ||
@@ -51,13 +47,1 @@ } | ||
exports.default = StructTreeItem; | ||
StructTreeItem.propTypes = { | ||
node: prop_types_1.default.oneOfType([ | ||
prop_types_1.default.shape({ | ||
children: prop_types_1.default.object, | ||
role: prop_types_1.default.string, | ||
}), | ||
prop_types_1.default.shape({ | ||
id: prop_types_1.default.string, | ||
type: prop_types_1.default.string, | ||
}), | ||
]).isRequired, | ||
}; |
@@ -1,4 +0,4 @@ | ||
/// <reference types="react" /> | ||
import type { PageProps } from './Page'; | ||
import type { ClassName, OnItemClickArgs } from './shared/types'; | ||
import React from 'react'; | ||
import type { PageProps } from './Page.js'; | ||
import type { ClassName, OnItemClickArgs } from './shared/types.js'; | ||
export type ThumbnailProps = Omit<PageProps, 'className' | 'customTextRenderer' | 'onGetAnnotationsError' | 'onGetAnnotationsSuccess' | 'onGetTextError' | 'onGetTextSuccess' | 'onRenderAnnotationLayerError' | 'onRenderAnnotationLayerSuccess' | 'onRenderTextLayerError' | 'onRenderTextLayerSuccess' | 'renderAnnotationLayer' | 'renderForms' | 'renderTextLayer'> & { | ||
@@ -8,2 +8,3 @@ className?: ClassName; | ||
}; | ||
export default function Thumbnail(props: ThumbnailProps): JSX.Element; | ||
declare const Thumbnail: React.FC<ThumbnailProps>; | ||
export default Thumbnail; |
@@ -21,15 +21,15 @@ "use strict"; | ||
const tiny_invariant_1 = __importDefault(require("tiny-invariant")); | ||
const Page_1 = __importDefault(require("./Page")); | ||
const utils_1 = require("./shared/utils"); | ||
const useDocumentContext_1 = __importDefault(require("./shared/hooks/useDocumentContext")); | ||
function Thumbnail(props) { | ||
const documentContext = (0, useDocumentContext_1.default)(); | ||
const Page_js_1 = __importDefault(require("./Page.js")); | ||
const utils_js_1 = require("./shared/utils.js"); | ||
const useDocumentContext_js_1 = __importDefault(require("./shared/hooks/useDocumentContext.js")); | ||
const Thumbnail = function Thumbnail(props) { | ||
const documentContext = (0, useDocumentContext_js_1.default)(); | ||
(0, tiny_invariant_1.default)(documentContext, 'Unable to find Document context. Did you wrap <Page /> in <Document />?'); | ||
const mergedProps = Object.assign(Object.assign({}, documentContext), props); | ||
const { className, linkService, onItemClick, pageIndex: pageIndexProps, pageNumber: pageNumberProps, } = mergedProps; | ||
const pageIndex = (0, utils_1.isProvided)(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null; | ||
const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : ((0, utils_1.isProvided)(pageIndexProps) ? pageIndexProps + 1 : null); | ||
const pageIndex = (0, utils_js_1.isProvided)(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null; | ||
const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : ((0, utils_js_1.isProvided)(pageIndexProps) ? pageIndexProps + 1 : null); | ||
function onClick(event) { | ||
event.preventDefault(); | ||
if (!(0, utils_1.isProvided)(pageIndex) || !pageNumber) { | ||
if (!(0, utils_js_1.isProvided)(pageIndex) || !pageNumber) { | ||
return; | ||
@@ -51,4 +51,4 @@ } | ||
react_1.default.createElement("a", { className: (0, clsx_1.default)('react-pdf__Thumbnail', className), href: pageNumber ? '#' : undefined, onClick: onClick }, | ||
react_1.default.createElement(Page_1.default, Object.assign({}, pageProps, { _className: "react-pdf__Thumbnail__page", _enableRegisterUnregisterPage: false, renderAnnotationLayer: false, renderTextLayer: false })))); | ||
} | ||
react_1.default.createElement(Page_js_1.default, Object.assign({}, pageProps, { _className: "react-pdf__Thumbnail__page", _enableRegisterUnregisterPage: false, renderAnnotationLayer: false, renderTextLayer: false })))); | ||
}; | ||
exports.default = Thumbnail; |
@@ -6,3 +6,3 @@ /** | ||
import type { EventProps } from 'make-event-props'; | ||
import type { ClassName, DocumentCallback, ExternalLinkRel, ExternalLinkTarget, File, ImageResourcesPath, NodeOrRenderer, OnDocumentLoadError, OnDocumentLoadProgress, OnDocumentLoadSuccess, OnError, OnItemClickArgs, OnPasswordCallback, Options, PasswordResponse, RenderMode } from './shared/types'; | ||
import type { ClassName, DocumentCallback, ExternalLinkRel, ExternalLinkTarget, File, ImageResourcesPath, NodeOrRenderer, OnDocumentLoadError, OnDocumentLoadProgress, OnDocumentLoadSuccess, OnError, OnItemClickArgs, OnPasswordCallback, Options, PasswordResponse, RenderMode } from './shared/types.js'; | ||
type OnItemClick = (args: OnItemClickArgs) => void; | ||
@@ -55,3 +55,3 @@ type OnPassword = (callback: OnPasswordCallback, reason: PasswordResponse) => void; | ||
rotate?: number | null | undefined; | ||
} & EventProps<false | import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined> & React.RefAttributes<unknown>>; | ||
} & EventProps<false | import("pdfjs-dist/types/src/display/api.js").PDFDocumentProxy | undefined> & React.RefAttributes<unknown>>; | ||
export default Document; |
@@ -33,9 +33,9 @@ 'use client'; | ||
import * as pdfjs from 'pdfjs-dist'; | ||
import DocumentContext from './DocumentContext'; | ||
import Message from './Message'; | ||
import LinkService from './LinkService'; | ||
import PasswordResponses from './PasswordResponses'; | ||
import { cancelRunningTask, dataURItoByteString, displayCORSWarning, isArrayBuffer, isBlob, isBrowser, isDataURI, loadFromFile, } from './shared/utils'; | ||
import useResolver from './shared/hooks/useResolver'; | ||
import { eventProps, isClassName, isFile, isRef } from './shared/propTypes'; | ||
import DocumentContext from './DocumentContext.js'; | ||
import Message from './Message.js'; | ||
import LinkService from './LinkService.js'; | ||
import PasswordResponses from './PasswordResponses.js'; | ||
import { cancelRunningTask, dataURItoByteString, displayCORSWarning, isArrayBuffer, isBlob, isBrowser, isDataURI, loadFromFile, } from './shared/utils.js'; | ||
import useResolver from './shared/hooks/useResolver.js'; | ||
import { eventProps, isClassName, isFile, isRef } from './shared/propTypes.js'; | ||
const { PDFDataRangeTransport } = pdfjs; | ||
@@ -42,0 +42,0 @@ const defaultOnPassword = (callback, reason) => { |
/// <reference types="react" /> | ||
import type { DocumentContextType } from './shared/types'; | ||
import type { DocumentContextType } from './shared/types.js'; | ||
declare const _default: import("react").Context<DocumentContextType>; | ||
export default _default; |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
export type { DocumentProps } from './Document'; | ||
export type { OutlineProps } from './Outline'; | ||
export type { PageProps } from './Page'; | ||
export type { ThumbnailProps } from './Thumbnail'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
export type { DocumentProps } from './Document.js'; | ||
export type { OutlineProps } from './Outline.js'; | ||
export type { PageProps } from './Page.js'; | ||
export type { ThumbnailProps } from './Thumbnail.js'; | ||
export { pdfjs, Document, Outline, Page, Thumbnail, useDocumentContext, useOutlineContext, usePageContext, }; |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
import { displayWorkerWarning } from './shared/utils'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
import { displayWorkerWarning } from './shared/utils.js'; | ||
displayWorkerWarning(); | ||
pdfjs.GlobalWorkerOptions.workerSrc = 'pdf.worker.js'; | ||
export { pdfjs, Document, Outline, Page, Thumbnail, useDocumentContext, useOutlineContext, usePageContext, }; |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
export type { DocumentProps } from './Document'; | ||
export type { OutlineProps } from './Outline'; | ||
export type { PageProps } from './Page'; | ||
export type { ThumbnailProps } from './Thumbnail'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
export type { DocumentProps } from './Document.js'; | ||
export type { OutlineProps } from './Outline.js'; | ||
export type { PageProps } from './Page.js'; | ||
export type { ThumbnailProps } from './Thumbnail.js'; | ||
import './pdf.worker.entry'; | ||
export { pdfjs, Document, Outline, Page, Thumbnail, useDocumentContext, useOutlineContext, usePageContext, }; |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
import './pdf.worker.entry'; | ||
export { pdfjs, Document, Outline, Page, Thumbnail, useDocumentContext, useOutlineContext, usePageContext, }; |
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
import type { Dest, ExternalLinkRel, ExternalLinkTarget, ScrollPageIntoViewArgs } from './shared/types'; | ||
import type { IPDFLinkService } from 'pdfjs-dist/types/web/interfaces'; | ||
import type { Dest, ExternalLinkRel, ExternalLinkTarget, ScrollPageIntoViewArgs } from './shared/types.js'; | ||
import type { IPDFLinkService } from 'pdfjs-dist/types/web/interfaces.js'; | ||
type PDFViewer = { | ||
@@ -5,0 +5,0 @@ currentPageNumber?: number; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
type MessageProps = { | ||
children: React.ReactNode; | ||
children?: React.ReactNode; | ||
type: 'error' | 'loading' | 'no-data'; | ||
}; | ||
declare function Message({ children, type }: MessageProps): JSX.Element; | ||
declare namespace Message { | ||
var propTypes: { | ||
children: PropTypes.Requireable<PropTypes.ReactNodeLike>; | ||
type: PropTypes.Validator<string>; | ||
}; | ||
} | ||
export default Message; | ||
export default function Message({ children, type }: MessageProps): JSX.Element; | ||
export {}; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
export default function Message({ children, type }) { | ||
return React.createElement("div", { className: `react-pdf__message react-pdf__message--${type}` }, children); | ||
} | ||
Message.propTypes = { | ||
children: PropTypes.node, | ||
type: PropTypes.oneOf(['error', 'loading', 'no-data']).isRequired, | ||
}; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
import type { EventProps } from 'make-event-props'; | ||
import type { OnItemClickArgs } from './shared/types'; | ||
import type { ClassName, OnItemClickArgs } from './shared/types.js'; | ||
type PDFOutline = Awaited<ReturnType<PDFDocumentProxy['getOutline']>>; | ||
export type OutlineProps = { | ||
className?: string; | ||
className?: ClassName; | ||
inputRef?: React.Ref<HTMLDivElement>; | ||
@@ -15,100 +14,3 @@ onItemClick?: (props: OnItemClickArgs) => void; | ||
} & EventProps<PDFOutline | null | false | undefined>; | ||
declare function Outline(props: OutlineProps): JSX.Element | null; | ||
declare namespace Outline { | ||
var propTypes: { | ||
className: PropTypes.Requireable<NonNullable<string | (string | null | undefined)[] | null | undefined>>; | ||
inputRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
onItemClick: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
pdf: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{ | ||
getDestination: PropTypes.Validator<(...args: any[]) => any>; | ||
getOutline: PropTypes.Validator<(...args: any[]) => any>; | ||
getPage: PropTypes.Validator<(...args: any[]) => any>; | ||
numPages: PropTypes.Validator<number>; | ||
}> | null | undefined>>; | ||
onCopy?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPaste?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onFocus?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onBlur?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInput?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onReset?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSubmit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInvalid?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoad?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onError?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyPress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAbort?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlayThrough?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDurationChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEmptied?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEncrypted?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEnded?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedData?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedMetadata?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPause?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlaying?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onProgress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onRateChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeked?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeking?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onStalled?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSuspend?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTimeUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onVolumeChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWaiting?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onContextMenu?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDoubleClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrag?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragExit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrop?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSelect?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onGotPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLostPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onScroll?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWheel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationIteration?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTransitionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onToggle?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
}; | ||
} | ||
declare const Outline: React.FC<OutlineProps>; | ||
export default Outline; |
@@ -20,9 +20,9 @@ 'use client'; | ||
import warning from 'tiny-warning'; | ||
import OutlineContext from './OutlineContext'; | ||
import OutlineItem from './OutlineItem'; | ||
import { cancelRunningTask } from './shared/utils'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useResolver from './shared/hooks/useResolver'; | ||
import { eventProps, isClassName, isPdf, isRef } from './shared/propTypes'; | ||
export default function Outline(props) { | ||
import OutlineContext from './OutlineContext.js'; | ||
import OutlineItem from './OutlineItem.js'; | ||
import { cancelRunningTask } from './shared/utils.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useResolver from './shared/hooks/useResolver.js'; | ||
import { eventProps, isClassName, isPdf, isRef } from './shared/propTypes.js'; | ||
const Outline = function Outline(props) { | ||
const documentContext = useDocumentContext(); | ||
@@ -108,3 +108,4 @@ invariant(documentContext, 'Unable to find Document context. Did you wrap <Outline /> in <Document />?'); | ||
React.createElement(OutlineContext.Provider, { value: childContext }, renderOutline()))); | ||
} | ||
}; | ||
Outline.propTypes = Object.assign(Object.assign({}, eventProps), { className: isClassName, inputRef: isRef, onItemClick: PropTypes.func, onLoadError: PropTypes.func, onLoadSuccess: PropTypes.func, pdf: isPdf }); | ||
export default Outline; |
/// <reference types="react" /> | ||
import type { OutlineContextType } from './shared/types'; | ||
import type { OutlineContextType } from './shared/types.js'; | ||
declare const _default: import("react").Context<OutlineContextType>; | ||
export default _default; |
/// <reference types="react" /> | ||
import PropTypes from 'prop-types'; | ||
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
@@ -9,15 +8,3 @@ type PDFOutline = Awaited<ReturnType<PDFDocumentProxy['getOutline']>>; | ||
}; | ||
declare function OutlineItem(props: OutlineItemProps): JSX.Element; | ||
declare namespace OutlineItem { | ||
var propTypes: { | ||
item: PropTypes.Validator<NonNullable<PropTypes.InferProps<{ | ||
dest: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>; | ||
items: PropTypes.Requireable<(PropTypes.InferProps<{ | ||
dest: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>; | ||
title: PropTypes.Requireable<string>; | ||
}> | null | undefined)[]>; | ||
title: PropTypes.Requireable<string>; | ||
}>>>; | ||
}; | ||
} | ||
export default OutlineItem; | ||
export default function OutlineItem(props: OutlineItemProps): JSX.Element; | ||
export {}; |
@@ -22,8 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import invariant from 'tiny-invariant'; | ||
import Ref from './Ref'; | ||
import useCachedValue from './shared/hooks/useCachedValue'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import Ref from './Ref.js'; | ||
import useCachedValue from './shared/hooks/useCachedValue.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
export default function OutlineItem(props) { | ||
@@ -81,12 +80,1 @@ const documentContext = useDocumentContext(); | ||
} | ||
const isDestination = PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.any)]); | ||
OutlineItem.propTypes = { | ||
item: PropTypes.shape({ | ||
dest: isDestination, | ||
items: PropTypes.arrayOf(PropTypes.shape({ | ||
dest: isDestination, | ||
title: PropTypes.string, | ||
})), | ||
title: PropTypes.string, | ||
}).isRequired, | ||
}; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import type { PDFDocumentProxy } from 'pdfjs-dist'; | ||
import type { EventProps } from 'make-event-props'; | ||
import type { CustomRenderer, CustomTextRenderer, NodeOrRenderer, OnGetAnnotationsError, OnGetAnnotationsSuccess, OnGetStructTreeError, OnGetStructTreeSuccess, OnGetTextError, OnGetTextSuccess, OnPageLoadError, OnPageLoadSuccess, OnRenderAnnotationLayerError, OnRenderAnnotationLayerSuccess, OnRenderError, OnRenderSuccess, OnRenderTextLayerError, OnRenderTextLayerSuccess, PageCallback, RenderMode } from './shared/types'; | ||
import type { ClassName, CustomRenderer, CustomTextRenderer, NodeOrRenderer, OnGetAnnotationsError, OnGetAnnotationsSuccess, OnGetStructTreeError, OnGetStructTreeSuccess, OnGetTextError, OnGetTextSuccess, OnPageLoadError, OnPageLoadSuccess, OnRenderAnnotationLayerError, OnRenderAnnotationLayerSuccess, OnRenderError, OnRenderSuccess, OnRenderTextLayerError, OnRenderTextLayerSuccess, PageCallback, RenderMode } from './shared/types.js'; | ||
export type PageProps = { | ||
@@ -12,3 +11,3 @@ _className?: string; | ||
children?: React.ReactNode; | ||
className?: string; | ||
className?: ClassName; | ||
customRenderer?: CustomRenderer; | ||
@@ -50,127 +49,3 @@ customTextRenderer?: CustomTextRenderer; | ||
} & EventProps<PageCallback | false | undefined>; | ||
declare function Page(props: PageProps): JSX.Element; | ||
declare namespace Page { | ||
var propTypes: { | ||
canvasBackground: PropTypes.Requireable<string>; | ||
canvasRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
children: PropTypes.Requireable<PropTypes.ReactNodeLike>; | ||
className: PropTypes.Requireable<NonNullable<string | (string | null | undefined)[] | null | undefined>>; | ||
customRenderer: PropTypes.Requireable<(...args: any[]) => any>; | ||
customTextRenderer: PropTypes.Requireable<(...args: any[]) => any>; | ||
devicePixelRatio: PropTypes.Requireable<number>; | ||
error: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>; | ||
height: PropTypes.Requireable<number>; | ||
imageResourcesPath: PropTypes.Requireable<string>; | ||
inputRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
loading: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>; | ||
noData: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike | ((...args: any[]) => any)>>; | ||
onGetTextError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onGetTextSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onLoadSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderTextLayerError: PropTypes.Requireable<(...args: any[]) => any>; | ||
onRenderTextLayerSuccess: PropTypes.Requireable<(...args: any[]) => any>; | ||
pageIndex: PropTypes.Validator<number>; | ||
pageNumber: PropTypes.Validator<number>; | ||
pdf: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{ | ||
getDestination: PropTypes.Validator<(...args: any[]) => any>; | ||
getOutline: PropTypes.Validator<(...args: any[]) => any>; | ||
getPage: PropTypes.Validator<(...args: any[]) => any>; | ||
numPages: PropTypes.Validator<number>; | ||
}> | null | undefined>>; | ||
renderAnnotationLayer: PropTypes.Requireable<boolean>; | ||
renderForms: PropTypes.Requireable<boolean>; | ||
renderMode: PropTypes.Requireable<string>; | ||
renderTextLayer: PropTypes.Requireable<boolean>; | ||
rotate: PropTypes.Requireable<number>; | ||
scale: PropTypes.Requireable<number>; | ||
width: PropTypes.Requireable<number>; | ||
onCopy?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPaste?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCompositionUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onFocus?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onBlur?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInput?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onReset?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSubmit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onInvalid?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoad?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onError?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyPress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onKeyUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAbort?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onCanPlayThrough?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDurationChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEmptied?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEncrypted?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onEnded?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedData?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadedMetadata?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLoadStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPause?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlay?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPlaying?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onProgress?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onRateChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeked?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSeeking?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onStalled?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSuspend?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTimeUpdate?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onVolumeChange?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWaiting?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onContextMenu?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDoubleClick?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrag?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragExit?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDragStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onDrop?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onMouseUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onSelect?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTouchStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerDown?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerMove?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerUp?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerCancel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerEnter?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerLeave?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOver?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onPointerOut?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onGotPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onLostPointerCapture?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onScroll?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onWheel?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationStart?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onAnimationIteration?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onTransitionEnd?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
onToggle?: PropTypes.Requireable<(...args: any[]) => any> | undefined; | ||
}; | ||
} | ||
declare const Page: React.FC<PageProps>; | ||
export default Page; |
@@ -21,14 +21,14 @@ 'use client'; | ||
import warning from 'tiny-warning'; | ||
import PageContext from './PageContext'; | ||
import Message from './Message'; | ||
import PageCanvas from './Page/PageCanvas'; | ||
import PageSVG from './Page/PageSVG'; | ||
import TextLayer from './Page/TextLayer'; | ||
import AnnotationLayer from './Page/AnnotationLayer'; | ||
import { cancelRunningTask, isProvided, makePageCallback } from './shared/utils'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useResolver from './shared/hooks/useResolver'; | ||
import { eventProps, isClassName, isPageIndex, isPageNumber, isPdf, isRef, isRenderMode, isRotate, } from './shared/propTypes'; | ||
import PageContext from './PageContext.js'; | ||
import Message from './Message.js'; | ||
import PageCanvas from './Page/PageCanvas.js'; | ||
import PageSVG from './Page/PageSVG.js'; | ||
import TextLayer from './Page/TextLayer.js'; | ||
import AnnotationLayer from './Page/AnnotationLayer.js'; | ||
import { cancelRunningTask, isProvided, makePageCallback } from './shared/utils.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useResolver from './shared/hooks/useResolver.js'; | ||
import { eventProps, isClassName, isPageIndex, isPageNumber, isPdf, isRef, isRenderMode, isRotate, } from './shared/propTypes.js'; | ||
const defaultScale = 1; | ||
export default function Page(props) { | ||
const Page = function Page(props) { | ||
const documentContext = useDocumentContext(); | ||
@@ -255,4 +255,5 @@ invariant(documentContext, 'Unable to find Document context. Did you wrap <Page /> in <Document />?'); | ||
} }, eventProps), renderContent())); | ||
} | ||
}; | ||
const isFunctionOrNode = PropTypes.oneOfType([PropTypes.func, PropTypes.node]); | ||
Page.propTypes = Object.assign(Object.assign({}, eventProps), { canvasBackground: PropTypes.string, canvasRef: isRef, children: PropTypes.node, className: isClassName, customRenderer: PropTypes.func, customTextRenderer: PropTypes.func, devicePixelRatio: PropTypes.number, error: isFunctionOrNode, height: PropTypes.number, imageResourcesPath: PropTypes.string, inputRef: isRef, loading: isFunctionOrNode, noData: isFunctionOrNode, onGetTextError: PropTypes.func, onGetTextSuccess: PropTypes.func, onLoadError: PropTypes.func, onLoadSuccess: PropTypes.func, onRenderError: PropTypes.func, onRenderSuccess: PropTypes.func, onRenderTextLayerError: PropTypes.func, onRenderTextLayerSuccess: PropTypes.func, pageIndex: isPageIndex, pageNumber: isPageNumber, pdf: isPdf, renderAnnotationLayer: PropTypes.bool, renderForms: PropTypes.bool, renderMode: isRenderMode, renderTextLayer: PropTypes.bool, rotate: isRotate, scale: PropTypes.number, width: PropTypes.number }); | ||
export default Page; |
@@ -8,6 +8,6 @@ 'use client'; | ||
import * as pdfjs from 'pdfjs-dist'; | ||
import useDocumentContext from '../shared/hooks/useDocumentContext'; | ||
import usePageContext from '../shared/hooks/usePageContext'; | ||
import useResolver from '../shared/hooks/useResolver'; | ||
import { cancelRunningTask } from '../shared/utils'; | ||
import useDocumentContext from '../shared/hooks/useDocumentContext.js'; | ||
import usePageContext from '../shared/hooks/usePageContext.js'; | ||
import useResolver from '../shared/hooks/useResolver.js'; | ||
import { cancelRunningTask } from '../shared/utils.js'; | ||
export default function AnnotationLayer() { | ||
@@ -14,0 +14,0 @@ const documentContext = useDocumentContext(); |
@@ -5,10 +5,3 @@ import React from 'react'; | ||
}; | ||
declare function PageCanvas(props: PageCanvasProps): JSX.Element; | ||
declare namespace PageCanvas { | ||
var propTypes: { | ||
canvasRef: import("prop-types").Requireable<NonNullable<((...args: any[]) => any) | Required<import("prop-types").InferProps<{ | ||
current: import("prop-types").Requireable<any>; | ||
}>> | null | undefined>>; | ||
}; | ||
} | ||
export default PageCanvas; | ||
export default function PageCanvas(props: PageCanvasProps): JSX.Element; | ||
export {}; |
@@ -7,6 +7,5 @@ 'use client'; | ||
import * as pdfjs from 'pdfjs-dist'; | ||
import StructTree from '../StructTree'; | ||
import usePageContext from '../shared/hooks/usePageContext'; | ||
import { cancelRunningTask, getDevicePixelRatio, isCancelException, makePageCallback, } from '../shared/utils'; | ||
import { isRef } from '../shared/propTypes'; | ||
import StructTree from '../StructTree.js'; | ||
import usePageContext from '../shared/hooks/usePageContext.js'; | ||
import { cancelRunningTask, getDevicePixelRatio, isCancelException, makePageCallback, } from '../shared/utils.js'; | ||
const ANNOTATION_MODE = pdfjs.AnnotationMode; | ||
@@ -109,4 +108,1 @@ export default function PageCanvas(props) { | ||
} | ||
PageCanvas.propTypes = { | ||
canvasRef: isRef, | ||
}; |
@@ -6,5 +6,5 @@ import React, { useEffect, useMemo } from 'react'; | ||
import * as pdfjs from 'pdfjs-dist'; | ||
import usePageContext from '../shared/hooks/usePageContext'; | ||
import useResolver from '../shared/hooks/useResolver'; | ||
import { cancelRunningTask, isCancelException, makePageCallback } from '../shared/utils'; | ||
import usePageContext from '../shared/hooks/usePageContext.js'; | ||
import useResolver from '../shared/hooks/useResolver.js'; | ||
import { cancelRunningTask, isCancelException, makePageCallback } from '../shared/utils.js'; | ||
export default function PageSVG() { | ||
@@ -11,0 +11,0 @@ const pageContext = usePageContext(); |
@@ -8,5 +8,5 @@ 'use client'; | ||
import * as pdfjs from 'pdfjs-dist'; | ||
import usePageContext from '../shared/hooks/usePageContext'; | ||
import useResolver from '../shared/hooks/useResolver'; | ||
import { cancelRunningTask } from '../shared/utils'; | ||
import usePageContext from '../shared/hooks/usePageContext.js'; | ||
import useResolver from '../shared/hooks/useResolver.js'; | ||
import { cancelRunningTask } from '../shared/utils.js'; | ||
function isTextItem(item) { | ||
@@ -13,0 +13,0 @@ return 'str' in item; |
/// <reference types="react" /> | ||
import type { PageContextType } from './shared/types'; | ||
import type { PageContextType } from './shared/types.js'; | ||
declare const _default: import("react").Context<PageContextType>; | ||
export default _default; |
'use client'; | ||
import { useRef } from 'react'; | ||
import { isDefined } from '../utils'; | ||
import { isDefined } from '../utils.js'; | ||
export default function useCachedValue(getter) { | ||
@@ -5,0 +5,0 @@ const ref = useRef(); |
@@ -1,1 +0,1 @@ | ||
export default function useDocumentContext(): import("../types").DocumentContextType; | ||
export default function useDocumentContext(): import("../types.js").DocumentContextType; |
import { useContext } from 'react'; | ||
import DocumentContext from '../../DocumentContext'; | ||
import DocumentContext from '../../DocumentContext.js'; | ||
export default function useDocumentContext() { | ||
return useContext(DocumentContext); | ||
} |
@@ -1,1 +0,1 @@ | ||
export default function useOutlineContext(): import("../types").OutlineContextType; | ||
export default function useOutlineContext(): import("../types.js").OutlineContextType; |
import { useContext } from 'react'; | ||
import OutlineContext from '../../OutlineContext'; | ||
import OutlineContext from '../../OutlineContext.js'; | ||
export default function useOutlineContext() { | ||
return useContext(OutlineContext); | ||
} |
@@ -1,1 +0,1 @@ | ||
export default function usePageContext(): import("../types").PageContextType; | ||
export default function usePageContext(): import("../types.js").PageContextType; |
import { useContext } from 'react'; | ||
import PageContext from '../../PageContext'; | ||
import PageContext from '../../PageContext.js'; | ||
export default function usePageContext() { | ||
return useContext(PageContext); | ||
} |
import PropTypes from 'prop-types'; | ||
import { allEvents } from 'make-event-props'; | ||
import { PDFDataRangeTransport } from 'pdfjs-dist'; | ||
import LinkService from '../LinkService'; | ||
import LinkService from '../LinkService.js'; | ||
import type { Validator } from 'prop-types'; | ||
@@ -20,3 +20,3 @@ type AllEvents = (typeof allEvents)[number]; | ||
export declare const isLinkService: PropTypes.Requireable<LinkService>; | ||
export declare const isLinkTarget: PropTypes.Requireable<string>; | ||
export declare const isLinkTarget: PropTypes.Requireable<"_self" | "_blank" | "_parent" | "_top">; | ||
export declare const isPage: PropTypes.Requireable<PropTypes.InferProps<{ | ||
@@ -31,13 +31,8 @@ commonObjs: PropTypes.Validator<NonNullable<PropTypes.InferProps<{}>>>; | ||
export declare const isPageNumber: Validator<number>; | ||
export declare const isPdf: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{ | ||
getDestination: PropTypes.Validator<(...args: any[]) => any>; | ||
getOutline: PropTypes.Validator<(...args: any[]) => any>; | ||
getPage: PropTypes.Validator<(...args: any[]) => any>; | ||
numPages: PropTypes.Validator<number>; | ||
}> | null | undefined>>; | ||
export declare const isPdf: PropTypes.Requireable<any>; | ||
export declare const isRef: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | Required<PropTypes.InferProps<{ | ||
current: PropTypes.Requireable<any>; | ||
}>> | null | undefined>>; | ||
export declare const isRenderMode: PropTypes.Requireable<string>; | ||
export declare const isRotate: PropTypes.Requireable<number>; | ||
export declare const isRenderMode: PropTypes.Requireable<"none" | "custom" | "canvas" | "svg">; | ||
export declare const isRotate: PropTypes.Requireable<0 | 90 | 180 | 270>; | ||
export {}; |
import PropTypes from 'prop-types'; | ||
import { allEvents } from 'make-event-props'; | ||
import { PDFDataRangeTransport } from 'pdfjs-dist'; | ||
import { isDefined } from './utils'; | ||
import LinkService from '../LinkService'; | ||
import { isDefined } from './utils.js'; | ||
import LinkService from '../LinkService.js'; | ||
export const eventProps = (() => { | ||
@@ -106,9 +106,5 @@ const result = {}; | ||
export const isPdf = PropTypes.oneOfType([ | ||
PropTypes.shape({ | ||
getDestination: PropTypes.func.isRequired, | ||
getOutline: PropTypes.func.isRequired, | ||
getPage: PropTypes.func.isRequired, | ||
numPages: PropTypes.number.isRequired, | ||
}), | ||
PropTypes.bool, | ||
// Ideally, this would be `PropTypes.instanceOf(PDFDocumentProxy)`, but it can't be imported. | ||
PropTypes.any, | ||
PropTypes.oneOf([false]), | ||
]); | ||
@@ -115,0 +111,0 @@ export const isRef = PropTypes.oneOfType([ |
/// <reference types="react" /> | ||
import { PDF_ROLE_TO_HTML_ROLE } from './constants'; | ||
import type { StructTreeContent, StructTreeNode } from 'pdfjs-dist/types/src/display/api'; | ||
import type { StructTreeNodeWithExtraAttributes } from './types'; | ||
import { PDF_ROLE_TO_HTML_ROLE } from './constants.js'; | ||
import type { StructTreeContent, StructTreeNode } from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { StructTreeNodeWithExtraAttributes } from './types.js'; | ||
type PdfRole = keyof typeof PDF_ROLE_TO_HTML_ROLE; | ||
@@ -6,0 +6,0 @@ type Attributes = React.HTMLAttributes<HTMLElement>; |
@@ -1,2 +0,2 @@ | ||
import { HEADING_PATTERN, PDF_ROLE_TO_HTML_ROLE } from './constants'; | ||
import { HEADING_PATTERN, PDF_ROLE_TO_HTML_ROLE } from './constants.js'; | ||
export function isPdfRole(role) { | ||
@@ -3,0 +3,0 @@ return role in PDF_ROLE_TO_HTML_ROLE; |
/// <reference types="react" /> | ||
import type { PDFDataRangeTransport, PDFDocumentProxy, PDFPageProxy, PasswordResponses } from 'pdfjs-dist'; | ||
import type { BinaryData, DocumentInitParameters, RefProxy, StructTreeNode, TextContent, TextItem } from 'pdfjs-dist/types/src/display/api'; | ||
import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer'; | ||
import type LinkService from '../LinkService'; | ||
import type { BinaryData, DocumentInitParameters, RefProxy, StructTreeNode, TextContent, TextItem } from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer.js'; | ||
import type LinkService from '../LinkService.js'; | ||
type NullableObject<T extends object> = { | ||
@@ -7,0 +7,0 @@ [P in keyof T]: T[P] | null; |
import type { PDFPageProxy } from 'pdfjs-dist'; | ||
import type { PageCallback } from './types'; | ||
import type { PageCallback } from './types.js'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Checks if we're running in a browser environment. |
@@ -5,6 +5,6 @@ import React, { useEffect } from 'react'; | ||
import warning from 'tiny-warning'; | ||
import StructTreeItem from './StructTreeItem'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
import useResolver from './shared/hooks/useResolver'; | ||
import { cancelRunningTask } from './shared/utils'; | ||
import StructTreeItem from './StructTreeItem.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
import useResolver from './shared/hooks/useResolver.js'; | ||
import { cancelRunningTask } from './shared/utils.js'; | ||
export default function StructTree() { | ||
@@ -11,0 +11,0 @@ const pageContext = usePageContext(); |
/// <reference types="react" /> | ||
import PropTypes from 'prop-types'; | ||
import type { StructTreeContent } from 'pdfjs-dist/types/src/display/api'; | ||
import type { StructTreeNodeWithExtraAttributes } from './shared/types'; | ||
import type { StructTreeContent } from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { StructTreeNodeWithExtraAttributes } from './shared/types.js'; | ||
type StructTreeItemProps = { | ||
@@ -9,14 +8,3 @@ className?: string; | ||
}; | ||
declare function StructTreeItem({ className, node }: StructTreeItemProps): JSX.Element; | ||
declare namespace StructTreeItem { | ||
var propTypes: { | ||
node: PropTypes.Validator<NonNullable<NonNullable<PropTypes.InferProps<{ | ||
children: PropTypes.Requireable<object>; | ||
role: PropTypes.Requireable<string>; | ||
}> | PropTypes.InferProps<{ | ||
id: PropTypes.Requireable<string>; | ||
type: PropTypes.Requireable<string>; | ||
}> | null | undefined>>>; | ||
}; | ||
} | ||
export default StructTreeItem; | ||
export default function StructTreeItem({ className, node }: StructTreeItemProps): JSX.Element; | ||
export {}; |
import React, { useMemo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { getAttributes, isStructTreeNode, isStructTreeNodeWithOnlyContentChild, } from './shared/structTreeUtils'; | ||
import { getAttributes, isStructTreeNode, isStructTreeNodeWithOnlyContentChild, } from './shared/structTreeUtils.js'; | ||
export default function StructTreeItem({ className, node }) { | ||
@@ -21,13 +20,1 @@ const attributes = useMemo(() => getAttributes(node), [node]); | ||
} | ||
StructTreeItem.propTypes = { | ||
node: PropTypes.oneOfType([ | ||
PropTypes.shape({ | ||
children: PropTypes.object, | ||
role: PropTypes.string, | ||
}), | ||
PropTypes.shape({ | ||
id: PropTypes.string, | ||
type: PropTypes.string, | ||
}), | ||
]).isRequired, | ||
}; |
@@ -1,4 +0,4 @@ | ||
/// <reference types="react" /> | ||
import type { PageProps } from './Page'; | ||
import type { ClassName, OnItemClickArgs } from './shared/types'; | ||
import React from 'react'; | ||
import type { PageProps } from './Page.js'; | ||
import type { ClassName, OnItemClickArgs } from './shared/types.js'; | ||
export type ThumbnailProps = Omit<PageProps, 'className' | 'customTextRenderer' | 'onGetAnnotationsError' | 'onGetAnnotationsSuccess' | 'onGetTextError' | 'onGetTextSuccess' | 'onRenderAnnotationLayerError' | 'onRenderAnnotationLayerSuccess' | 'onRenderTextLayerError' | 'onRenderTextLayerSuccess' | 'renderAnnotationLayer' | 'renderForms' | 'renderTextLayer'> & { | ||
@@ -8,2 +8,3 @@ className?: ClassName; | ||
}; | ||
export default function Thumbnail(props: ThumbnailProps): JSX.Element; | ||
declare const Thumbnail: React.FC<ThumbnailProps>; | ||
export default Thumbnail; |
@@ -16,6 +16,6 @@ 'use client'; | ||
import invariant from 'tiny-invariant'; | ||
import Page from './Page'; | ||
import { isProvided } from './shared/utils'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
export default function Thumbnail(props) { | ||
import Page from './Page.js'; | ||
import { isProvided } from './shared/utils.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
const Thumbnail = function Thumbnail(props) { | ||
const documentContext = useDocumentContext(); | ||
@@ -47,2 +47,3 @@ invariant(documentContext, 'Unable to find Document context. Did you wrap <Page /> in <Document />?'); | ||
React.createElement(Page, Object.assign({}, pageProps, { _className: "react-pdf__Thumbnail__page", _enableRegisterUnregisterPage: false, renderAnnotationLayer: false, renderTextLayer: false })))); | ||
} | ||
}; | ||
export default Thumbnail; |
{ | ||
"name": "react-pdf", | ||
"version": "7.2.0", | ||
"version": "7.3.0", | ||
"description": "Display PDFs in your React app as easily as if they were images.", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"source": "src/index.ts", | ||
"types": "dist/cjs/index.d.ts", | ||
"type": "module", | ||
"sideEffects": [ | ||
"*.css" | ||
], | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"source": "./src/index.ts", | ||
"types": "./dist/cjs/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js" | ||
}, | ||
"./dist/cjs/Page/AnnotationLayer.css": "./dist/cjs/Page/AnnotationLayer.css", | ||
"./dist/cjs/Page/TextLayer.css": "./dist/cjs/Page/TextLayer.css", | ||
"./dist/esm/Page/AnnotationLayer.css": "./dist/esm/Page/AnnotationLayer.css", | ||
"./dist/esm/Page/TextLayer.css": "./dist/esm/Page/TextLayer.css" | ||
}, | ||
"scripts": { | ||
"build": "yarn build-js && yarn copy-styles", | ||
"build-js": "yarn build-js-esm && yarn build-js-cjs", | ||
"build-js": "yarn build-js-esm && yarn build-js-cjs && yarn build-js-cjs-package", | ||
"build-js-esm": "tsc --project tsconfig.build.json --outDir dist/esm --module esnext", | ||
"build-js-cjs": "tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs", | ||
"build-js-cjs-package": "echo '{\n \"type\": \"commonjs\"\n}' > dist/cjs/package.json", | ||
"clean": "rimraf dist", | ||
"copy-styles": "node --loader ts-node/esm ./copy-styles.ts", | ||
"copy-styles": "cpy 'src/**/*.css' dist/esm && cpy 'src/**/*.css' dist/cjs", | ||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx", | ||
@@ -24,3 +36,4 @@ "prepack": "yarn clean && yarn build", | ||
"tsc": "tsc --noEmit", | ||
"unit": "vitest" | ||
"unit": "vitest", | ||
"watch": "yarn build-js-esm --watch & yarn build-js-cjs --watch & yarn build-js-cjs-package & nodemon --watch src --ext css --exec \"yarn copy-styles\"" | ||
}, | ||
@@ -40,3 +53,3 @@ "keywords": [ | ||
"make-cancellable-promise": "^1.3.1", | ||
"make-event-props": "^1.5.0", | ||
"make-event-props": "^1.6.0", | ||
"merge-refs": "^1.2.1", | ||
@@ -55,2 +68,3 @@ "pdfjs-dist": "3.6.172", | ||
"@types/react": "*", | ||
"cpy-cli": "^5.0.0", | ||
"eslint": "^8.26.0", | ||
@@ -60,2 +74,3 @@ "eslint-config-wojtekmaj": "^0.9.0", | ||
"jsdom": "^21.1.0", | ||
"nodemon": "^3.0.0", | ||
"prettier": "^2.7.0", | ||
@@ -66,3 +81,2 @@ "pretty-quick": "^3.1.0", | ||
"rimraf": "^3.0.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.0", | ||
@@ -69,0 +83,0 @@ "vitest": "^0.30.1", |
import { describe, expect, it } from 'vitest'; | ||
import { pdfjs, Document, Outline, Page } from './index'; | ||
import { pdfjs, Document, Outline, Page } from './index.js'; | ||
@@ -4,0 +4,0 @@ describe('default entry', () => { |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
export type { DocumentProps } from './Document'; | ||
export type { OutlineProps } from './Outline'; | ||
export type { PageProps } from './Page'; | ||
export type { ThumbnailProps } from './Thumbnail'; | ||
export type { DocumentProps } from './Document.js'; | ||
export type { OutlineProps } from './Outline.js'; | ||
export type { PageProps } from './Page.js'; | ||
export type { ThumbnailProps } from './Thumbnail.js'; | ||
@@ -17,0 +17,0 @@ import './pdf.worker.entry'; |
import * as pdfjs from 'pdfjs-dist'; | ||
import Document from './Document'; | ||
import Outline from './Outline'; | ||
import Page from './Page'; | ||
import Thumbnail from './Thumbnail'; | ||
import Document from './Document.js'; | ||
import Outline from './Outline.js'; | ||
import Page from './Page.js'; | ||
import Thumbnail from './Thumbnail.js'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext'; | ||
import usePageContext from './shared/hooks/usePageContext'; | ||
import useDocumentContext from './shared/hooks/useDocumentContext.js'; | ||
import useOutlineContext from './shared/hooks/useOutlineContext.js'; | ||
import usePageContext from './shared/hooks/usePageContext.js'; | ||
export type { DocumentProps } from './Document'; | ||
export type { OutlineProps } from './Outline'; | ||
export type { PageProps } from './Page'; | ||
export type { ThumbnailProps } from './Thumbnail'; | ||
export type { DocumentProps } from './Document.js'; | ||
export type { OutlineProps } from './Outline.js'; | ||
export type { PageProps } from './Page.js'; | ||
export type { ThumbnailProps } from './Thumbnail.js'; | ||
import { displayWorkerWarning } from './shared/utils'; | ||
import { displayWorkerWarning } from './shared/utils.js'; | ||
@@ -19,0 +19,0 @@ displayWorkerWarning(); |
@@ -24,5 +24,5 @@ /* Copyright 2015 Mozilla Foundation | ||
ScrollPageIntoViewArgs, | ||
} from './shared/types'; | ||
} from './shared/types.js'; | ||
import type { IPDFLinkService } from 'pdfjs-dist/types/web/interfaces'; | ||
import type { IPDFLinkService } from 'pdfjs-dist/types/web/interfaces.js'; | ||
@@ -29,0 +29,0 @@ const DEFAULT_LINK_REL = 'noopener noreferrer nofollow'; |
import { describe, expect, it } from 'vitest'; | ||
import Ref from './Ref'; | ||
import Ref from './Ref.js'; | ||
@@ -4,0 +4,0 @@ describe('Ref', () => { |
@@ -5,3 +5,3 @@ 'use client'; | ||
import { isDefined } from '../utils'; | ||
import { isDefined } from '../utils.js'; | ||
@@ -8,0 +8,0 @@ export default function useCachedValue<T>(getter: () => T): () => T { |
import { useContext } from 'react'; | ||
import DocumentContext from '../../DocumentContext'; | ||
import DocumentContext from '../../DocumentContext.js'; | ||
@@ -5,0 +5,0 @@ export default function useDocumentContext() { |
import { useContext } from 'react'; | ||
import OutlineContext from '../../OutlineContext'; | ||
import OutlineContext from '../../OutlineContext.js'; | ||
@@ -5,0 +5,0 @@ export default function useOutlineContext() { |
import { useContext } from 'react'; | ||
import PageContext from '../../PageContext'; | ||
import PageContext from '../../PageContext.js'; | ||
@@ -5,0 +5,0 @@ export default function usePageContext() { |
@@ -5,5 +5,5 @@ import PropTypes from 'prop-types'; | ||
import { isDefined } from './utils'; | ||
import { isDefined } from './utils.js'; | ||
import LinkService from '../LinkService'; | ||
import LinkService from '../LinkService.js'; | ||
@@ -71,3 +71,3 @@ import type { Validator } from 'prop-types'; | ||
export const isLinkTarget = PropTypes.oneOf(['_self', '_blank', '_parent', '_top']); | ||
export const isLinkTarget = PropTypes.oneOf(['_self', '_blank', '_parent', '_top'] as const); | ||
@@ -153,9 +153,5 @@ export const isPage = PropTypes.shape({ | ||
export const isPdf = PropTypes.oneOfType([ | ||
PropTypes.shape({ | ||
getDestination: PropTypes.func.isRequired, | ||
getOutline: PropTypes.func.isRequired, | ||
getPage: PropTypes.func.isRequired, | ||
numPages: PropTypes.number.isRequired, | ||
}), | ||
PropTypes.bool, | ||
// Ideally, this would be `PropTypes.instanceOf(PDFDocumentProxy)`, but it can't be imported. | ||
PropTypes.any, | ||
PropTypes.oneOf([false] as const), | ||
]); | ||
@@ -170,4 +166,4 @@ | ||
export const isRenderMode = PropTypes.oneOf(['canvas', 'custom', 'none', 'svg']); | ||
export const isRenderMode = PropTypes.oneOf(['canvas', 'custom', 'none', 'svg'] as const); | ||
export const isRotate = PropTypes.oneOf([0, 90, 180, 270]); | ||
export const isRotate = PropTypes.oneOf([0, 90, 180, 270] as const); |
@@ -1,5 +0,5 @@ | ||
import { HEADING_PATTERN, PDF_ROLE_TO_HTML_ROLE } from './constants'; | ||
import { HEADING_PATTERN, PDF_ROLE_TO_HTML_ROLE } from './constants.js'; | ||
import type { StructTreeContent, StructTreeNode } from 'pdfjs-dist/types/src/display/api'; | ||
import type { StructTreeNodeWithExtraAttributes } from './types'; | ||
import type { StructTreeContent, StructTreeNode } from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { StructTreeNodeWithExtraAttributes } from './types.js'; | ||
@@ -6,0 +6,0 @@ type PdfRole = keyof typeof PDF_ROLE_TO_HTML_ROLE; |
@@ -14,5 +14,5 @@ import type { | ||
TextItem, | ||
} from 'pdfjs-dist/types/src/display/api'; | ||
import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer'; | ||
import type LinkService from '../LinkService'; | ||
} from 'pdfjs-dist/types/src/display/api.js'; | ||
import type { AnnotationLayerParameters } from 'pdfjs-dist/types/src/display/annotation_layer.js'; | ||
import type LinkService from '../LinkService.js'; | ||
@@ -19,0 +19,0 @@ type NullableObject<T extends object> = { [P in keyof T]: T[P] | null }; |
import { describe, expect, it } from 'vitest'; | ||
import { isDataURI, dataURItoByteString } from './utils'; | ||
import { isDataURI, dataURItoByteString } from './utils.js'; | ||
@@ -4,0 +4,0 @@ describe('isDataURI()', () => { |
@@ -5,3 +5,3 @@ import invariant from 'tiny-invariant'; | ||
import type { PDFPageProxy } from 'pdfjs-dist'; | ||
import type { PageCallback } from './types'; | ||
import type { PageCallback } from './types.js'; | ||
@@ -8,0 +8,0 @@ /** |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178
618
Yes
579013
20
12733
Updatedmake-event-props@^1.6.0