🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-pdf

Package Overview
Dependencies
Maintainers
1
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pdf - npm Package Compare versions

Comparing version

to
7.7.1

5

dist/cjs/Outline.js

@@ -61,6 +61,5 @@ "use strict";

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 mergedProps = Object.assign(Object.assign({}, documentContext), props);
const { className, inputRef, onItemClick, onLoadError: onLoadErrorProps, onLoadSuccess: onLoadSuccessProps, pdf } = mergedProps, otherProps = __rest(mergedProps, ["className", "inputRef", "onItemClick", "onLoadError", "onLoadSuccess", "pdf"]);
(0, tiny_invariant_1.default)(pdf, 'Attempted to load an outline, but no document was specified.');
(0, tiny_invariant_1.default)(pdf, 'Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.');
const [outlineState, outlineDispatch] = (0, useResolver_js_1.default)();

@@ -137,3 +136,3 @@ const { value: outline, error: outlineError } = outlineState;

}
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("ul", null, outline.map((item, itemIndex) => (react_1.default.createElement(OutlineItem_js_1.default, { key: typeof item.dest === 'string' ? item.dest : itemIndex, item: item, pdf: pdf })))));
}

@@ -140,0 +139,0 @@ return (react_1.default.createElement("div", Object.assign({ className: (0, clsx_1.default)('react-pdf__Outline', className), ref: inputRef }, eventProps),

1

dist/cjs/OutlineItem.d.ts

@@ -7,4 +7,5 @@ /// <reference types="react" />

item: PDFOutlineItem;
pdf?: PDFDocumentProxy | false;
};
export default function OutlineItem(props: OutlineItemProps): JSX.Element;
export {};

@@ -34,3 +34,2 @@ "use strict";

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_js_1.default)();

@@ -40,3 +39,3 @@ (0, tiny_invariant_1.default)(outlineContext, 'Unable to find Outline context.');

const { item, linkService, onItemClick, pdf } = mergedProps, otherProps = __rest(mergedProps, ["item", "linkService", "onItemClick", "pdf"]);
(0, tiny_invariant_1.default)(pdf, 'Attempted to load an outline, but no document was specified.');
(0, tiny_invariant_1.default)(pdf, 'Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.');
const getDestination = (0, useCachedValue_js_1.default)(() => {

@@ -62,2 +61,3 @@ if (typeof item.dest === 'string') {

event.preventDefault();
(0, tiny_invariant_1.default)(onItemClick || linkService, 'Either onItemClick callback or linkService must be defined in order to navigate to an outline item.');
if (onItemClick) {

@@ -72,3 +72,3 @@ Promise.all([getDestination(), getPageIndex(), getPageNumber()]).then(([dest, pageIndex, pageNumber]) => {

}
else {
else if (linkService) {
linkService.goToDestination(item.dest);

@@ -82,3 +82,3 @@ }

const { items: subitems } = item;
return (react_1.default.createElement("ul", null, subitems.map((subitem, subitemIndex) => (react_1.default.createElement(OutlineItem, Object.assign({ key: typeof subitem.dest === 'string' ? subitem.dest : subitemIndex, item: subitem }, otherProps))))));
return (react_1.default.createElement("ul", null, subitems.map((subitem, subitemIndex) => (react_1.default.createElement(OutlineItem, Object.assign({ key: typeof subitem.dest === 'string' ? subitem.dest : subitemIndex, item: subitem, pdf: pdf }, otherProps))))));
}

@@ -85,0 +85,0 @@ return (react_1.default.createElement("li", null,

@@ -67,3 +67,2 @@ "use strict";

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);

@@ -74,3 +73,3 @@ 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 pageElement = (0, react_1.useRef)(null);
(0, tiny_invariant_1.default)(pdf, 'Attempted to load a page, but no document was specified.');
(0, tiny_invariant_1.default)(pdf, 'Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.');
const pageIndex = (0, utils_js_1.isProvided)(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null;

@@ -77,0 +76,0 @@ const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : ((0, utils_js_1.isProvided)(pageIndexProps) ? pageIndexProps + 1 : null);

@@ -42,3 +42,2 @@ "use strict";

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_js_1.default)();

@@ -48,3 +47,5 @@ (0, tiny_invariant_1.default)(pageContext, 'Unable to find Page context.');

const { imageResourcesPath, linkService, onGetAnnotationsError: onGetAnnotationsErrorProps, onGetAnnotationsSuccess: onGetAnnotationsSuccessProps, onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps, onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps, page, pdf, renderForms, rotate, scale = 1, } = mergedProps;
(0, tiny_invariant_1.default)(pdf, 'Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.');
(0, tiny_invariant_1.default)(page, 'Attempted to load page annotations, but no page was specified.');
(0, tiny_invariant_1.default)(linkService, 'Attempted to load page annotations, but no linkService was specified.');
const [annotationsState, annotationsDispatch] = (0, useResolver_js_1.default)();

@@ -121,3 +122,3 @@ const { value: annotations, error: annotationsError } = annotationsState;

function renderAnnotationLayer() {
if (!pdf || !page || !annotations) {
if (!pdf || !page || !linkService || !annotations) {
return;

@@ -124,0 +125,0 @@ }

@@ -31,5 +31,5 @@ "use strict";

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 { className, linkService, onItemClick, pageIndex: pageIndexProps, pageNumber: pageNumberProps, pdf, } = mergedProps;
(0, tiny_invariant_1.default)(pdf, 'Attempted to load a thumbnail, but no document was specified. Wrap <Thumbnail /> in a <Document /> or pass explicit `pdf` prop.');
const pageIndex = (0, utils_js_1.isProvided)(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null;

@@ -42,2 +42,3 @@ const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : ((0, utils_js_1.isProvided)(pageIndexProps) ? pageIndexProps + 1 : null);

}
(0, tiny_invariant_1.default)(onItemClick || linkService, 'Either onItemClick callback or linkService must be defined in order to navigate to an outline item.');
if (onItemClick) {

@@ -49,3 +50,3 @@ onItemClick({

}
else {
else if (linkService) {
linkService.goToPage(pageNumber);

@@ -52,0 +53,0 @@ }

@@ -33,6 +33,5 @@ 'use client';

const documentContext = useDocumentContext();
invariant(documentContext, 'Unable to find Document context. Did you wrap <Outline /> in <Document />?');
const mergedProps = Object.assign(Object.assign({}, documentContext), props);
const { className, inputRef, onItemClick, onLoadError: onLoadErrorProps, onLoadSuccess: onLoadSuccessProps, pdf } = mergedProps, otherProps = __rest(mergedProps, ["className", "inputRef", "onItemClick", "onLoadError", "onLoadSuccess", "pdf"]);
invariant(pdf, 'Attempted to load an outline, but no document was specified.');
invariant(pdf, 'Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.');
const [outlineState, outlineDispatch] = useResolver();

@@ -109,3 +108,3 @@ const { value: outline, error: outlineError } = outlineState;

}
return (React.createElement("ul", null, outline.map((item, itemIndex) => (React.createElement(OutlineItem, { key: typeof item.dest === 'string' ? item.dest : itemIndex, item: item })))));
return (React.createElement("ul", null, outline.map((item, itemIndex) => (React.createElement(OutlineItem, { key: typeof item.dest === 'string' ? item.dest : itemIndex, item: item, pdf: pdf })))));
}

@@ -112,0 +111,0 @@ return (React.createElement("div", Object.assign({ className: clsx('react-pdf__Outline', className), ref: inputRef }, eventProps),

@@ -7,4 +7,5 @@ /// <reference types="react" />

item: PDFOutlineItem;
pdf?: PDFDocumentProxy | false;
};
export default function OutlineItem(props: OutlineItemProps): JSX.Element;
export {};

@@ -29,3 +29,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const documentContext = useDocumentContext();
invariant(documentContext, 'Unable to find Document context. Did you wrap <Outline /> in <Document />?');
const outlineContext = useOutlineContext();

@@ -35,3 +34,3 @@ invariant(outlineContext, 'Unable to find Outline context.');

const { item, linkService, onItemClick, pdf } = mergedProps, otherProps = __rest(mergedProps, ["item", "linkService", "onItemClick", "pdf"]);
invariant(pdf, 'Attempted to load an outline, but no document was specified.');
invariant(pdf, 'Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.');
const getDestination = useCachedValue(() => {

@@ -57,2 +56,3 @@ if (typeof item.dest === 'string') {

event.preventDefault();
invariant(onItemClick || linkService, 'Either onItemClick callback or linkService must be defined in order to navigate to an outline item.');
if (onItemClick) {

@@ -67,3 +67,3 @@ Promise.all([getDestination(), getPageIndex(), getPageNumber()]).then(([dest, pageIndex, pageNumber]) => {

}
else {
else if (linkService) {
linkService.goToDestination(item.dest);

@@ -77,3 +77,3 @@ }

const { items: subitems } = item;
return (React.createElement("ul", null, subitems.map((subitem, subitemIndex) => (React.createElement(OutlineItem, Object.assign({ key: typeof subitem.dest === 'string' ? subitem.dest : subitemIndex, item: subitem }, otherProps))))));
return (React.createElement("ul", null, subitems.map((subitem, subitemIndex) => (React.createElement(OutlineItem, Object.assign({ key: typeof subitem.dest === 'string' ? subitem.dest : subitemIndex, item: subitem, pdf: pdf }, otherProps))))));
}

@@ -80,0 +80,0 @@ return (React.createElement("li", null,

@@ -39,3 +39,2 @@ 'use client';

const documentContext = useDocumentContext();
invariant(documentContext, 'Unable to find Document context. Did you wrap <Page /> in <Document />?');
const mergedProps = Object.assign(Object.assign({}, documentContext), props);

@@ -46,3 +45,3 @@ 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 pageElement = useRef(null);
invariant(pdf, 'Attempted to load a page, but no document was specified.');
invariant(pdf, 'Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.');
const pageIndex = isProvided(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null;

@@ -49,0 +48,0 @@ const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : (isProvided(pageIndexProps) ? pageIndexProps + 1 : null);

@@ -14,3 +14,2 @@ 'use client';

const documentContext = useDocumentContext();
invariant(documentContext, 'Unable to find Document context. Did you wrap <Page /> in <Document />?');
const pageContext = usePageContext();

@@ -20,3 +19,5 @@ invariant(pageContext, 'Unable to find Page context.');

const { imageResourcesPath, linkService, onGetAnnotationsError: onGetAnnotationsErrorProps, onGetAnnotationsSuccess: onGetAnnotationsSuccessProps, onRenderAnnotationLayerError: onRenderAnnotationLayerErrorProps, onRenderAnnotationLayerSuccess: onRenderAnnotationLayerSuccessProps, page, pdf, renderForms, rotate, scale = 1, } = mergedProps;
invariant(pdf, 'Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.');
invariant(page, 'Attempted to load page annotations, but no page was specified.');
invariant(linkService, 'Attempted to load page annotations, but no linkService was specified.');
const [annotationsState, annotationsDispatch] = useResolver();

@@ -93,3 +94,3 @@ const { value: annotations, error: annotationsError } = annotationsState;

function renderAnnotationLayer() {
if (!pdf || !page || !annotations) {
if (!pdf || !page || !linkService || !annotations) {
return;

@@ -96,0 +97,0 @@ }

@@ -26,5 +26,5 @@ 'use client';

const documentContext = useDocumentContext();
invariant(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 { className, linkService, onItemClick, pageIndex: pageIndexProps, pageNumber: pageNumberProps, pdf, } = mergedProps;
invariant(pdf, 'Attempted to load a thumbnail, but no document was specified. Wrap <Thumbnail /> in a <Document /> or pass explicit `pdf` prop.');
const pageIndex = isProvided(pageNumberProps) ? pageNumberProps - 1 : pageIndexProps !== null && pageIndexProps !== void 0 ? pageIndexProps : null;

@@ -37,2 +37,3 @@ const pageNumber = pageNumberProps !== null && pageNumberProps !== void 0 ? pageNumberProps : (isProvided(pageIndexProps) ? pageIndexProps + 1 : null);

}
invariant(onItemClick || linkService, 'Either onItemClick callback or linkService must be defined in order to navigate to an outline item.');
if (onItemClick) {

@@ -44,3 +45,3 @@ onItemClick({

}
else {
else if (linkService) {
linkService.goToPage(pageNumber);

@@ -47,0 +48,0 @@ }

{
"name": "react-pdf",
"version": "7.7.0",
"version": "7.7.1",
"description": "Display PDFs in your React app as easily as if they were images.",

@@ -77,5 +77,5 @@ "type": "module",

"cpy-cli": "^5.0.0",
"eslint": "^8.26.0",
"eslint-config-wojtekmaj": "^0.9.0",
"jsdom": "^21.1.0",
"eslint": "^8.56.0",
"eslint-config-wojtekmaj": "^0.11.0",
"jsdom": "^24.0.0",
"nodemon": "^3.0.0",

@@ -82,0 +82,0 @@ "prettier": "^3.0.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