MCPcopy Create free account
hub / github.com/alephdata/aleph / fetchComponents

Method fetchComponents

ui/src/viewers/PdfViewer.jsx:149–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

147 }
148
149 fetchComponents() {
150 import(/* webpackChunkName:'pdf-lib' */ 'react-pdf').then(
151 ({ Document, Page, pdfjs }) => {
152 // Webpack will copy `pdf.worker.min.js` to the build directory and automatically
153 // include a file hash in the file name to handle browser cache invalidation.
154 // See: https://github.com/wojtekmaj/react-pdf#import-worker-recommended
155 // See: https://webpack.js.org/guides/asset-modules/#url-assets
156 pdfjs.GlobalWorkerOptions.workerSrc = new URL(
157 // The leading `!!` disables all configured loaders that are usually applied for
158 // JS files as the worker file is already bundled and optimized for distribution.
159 // See: https://webpack.js.org/concepts/loaders/#inline
160 '!!pdfjs-dist/build/pdf.worker.min.js',
161 import.meta.url
162 ).toString();
163
164 this.setState({ components: { Document, Page } });
165 }
166 );
167 }
168
169 renderPdf() {
170 const { document, page, rotate, numPages, pdfUrl } = this.props;

Callers 1

componentDidMountMethod · 0.95

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected