From 3dc0567a37e3883f53f316e5bca14ce4231670f2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 1 May 2020 12:31:25 +0200 Subject: [PATCH] Remove the `create-react-app` example (issue 11729) Given that none of the PDF.js contributors know React, maintaining and/or providing supporting for the example isn't really feasible unfortunately. Even something as simple as running/testing the example becomes difficult for anyone completely unfamiliar with React, and furthermore: - It's very difficult to tell if the example demonstrates React best-practices, since the PDF.js contributors don't know React. - We also have no reasonable way of keeping the example up-to-date with changes in React. - The React example, in its current form, is even *hard-coding* the PDF.js version to a now unsupported version. - The example is currently triggering "fake worker" usage, see issue 11729, which is really *really* bad. Note that the "fake worker" functionality is *only* intended as a fallback, and it should absolutely *not* under any circumstances be advertised and certainly shouldn't be triggered in official PDF.js examples. --- examples/create-react-app/.env | 1 - examples/create-react-app/.gitignore | 24 ------- examples/create-react-app/README.md | 68 ------------------ examples/create-react-app/package.json | 38 ---------- examples/create-react-app/public/favicon.ico | Bin 22382 -> 0 bytes .../create-react-app/public/helloworld.pdf | 68 ------------------ examples/create-react-app/public/index.html | 43 ----------- .../create-react-app/public/manifest.json | 15 ---- examples/create-react-app/public/robots.txt | 2 - examples/create-react-app/src/app.tsx | 12 ---- examples/create-react-app/src/index.css | 11 --- examples/create-react-app/src/index.tsx | 7 -- examples/create-react-app/src/pdf.tsx | 62 ---------------- .../create-react-app/src/react-app-env.d.ts | 1 - examples/create-react-app/tsconfig.json | 25 ------- 15 files changed, 377 deletions(-) delete mode 100644 examples/create-react-app/.env delete mode 100644 examples/create-react-app/.gitignore delete mode 100644 examples/create-react-app/README.md delete mode 100644 examples/create-react-app/package.json delete mode 100644 examples/create-react-app/public/favicon.ico delete mode 100644 examples/create-react-app/public/helloworld.pdf delete mode 100644 examples/create-react-app/public/index.html delete mode 100644 examples/create-react-app/public/manifest.json delete mode 100644 examples/create-react-app/public/robots.txt delete mode 100644 examples/create-react-app/src/app.tsx delete mode 100644 examples/create-react-app/src/index.css delete mode 100644 examples/create-react-app/src/index.tsx delete mode 100644 examples/create-react-app/src/pdf.tsx delete mode 100644 examples/create-react-app/src/react-app-env.d.ts delete mode 100644 examples/create-react-app/tsconfig.json diff --git a/examples/create-react-app/.env b/examples/create-react-app/.env deleted file mode 100644 index 7d910f148..000000000 --- a/examples/create-react-app/.env +++ /dev/null @@ -1 +0,0 @@ -SKIP_PREFLIGHT_CHECK=true \ No newline at end of file diff --git a/examples/create-react-app/.gitignore b/examples/create-react-app/.gitignore deleted file mode 100644 index 7d3cec2ef..000000000 --- a/examples/create-react-app/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* -yarn.lock diff --git a/examples/create-react-app/README.md b/examples/create-react-app/README.md deleted file mode 100644 index 89b278ae3..000000000 --- a/examples/create-react-app/README.md +++ /dev/null @@ -1,68 +0,0 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `yarn start` - -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `yarn build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify diff --git a/examples/create-react-app/package.json b/examples/create-react-app/package.json deleted file mode 100644 index 00a037c27..000000000 --- a/examples/create-react-app/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "create-react-app", - "version": "0.1.0", - "private": true, - "dependencies": { - "pdfjs-dist": "^2.2.228", - "react": "^16.10.2", - "react-dom": "^16.10.2", - "react-scripts": "3.2.0" - }, - "devDependencies": { - "@types/jest": "^24.0.18", - "@types/node": "^12.7.12", - "@types/react": "^16.9.5", - "@types/react-dom": "^16.9.1", - "eslint-config-react-app": "^5.0.2", - "eslint-plugin-react-hooks": "^2.1.2", - "typescript": "^3.6.3" - }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } -} diff --git a/examples/create-react-app/public/favicon.ico b/examples/create-react-app/public/favicon.ico deleted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gsNVnQia$ zZgC^uxM^R6{*x;p4%GUm4cni`FH6sJRYn6knuJqqUp@vJM_1N0idKwLrYGuyxF-q?8KL+a+I8rUOfw_5oB2lD5f;d3X4 zJ5Ah&WdE1FA3)secO`Rp62r5<~m_U#9gdeUyLKJ9CbYQqHy>{e|9{^t8& zegB|7>&clAck|MNVbeFrktOvg3z02+fklW+i z75E(uea`*)|61hwI0Glv#osFTd$jcF+lgF`R(}5r_>AF1E=RLI|J&#PL|*%vcRjTR QPNaAH_W=L@JAozeZ|l@fegFUf diff --git a/examples/create-react-app/public/helloworld.pdf b/examples/create-react-app/public/helloworld.pdf deleted file mode 100644 index d98b4e1db..000000000 --- a/examples/create-react-app/public/helloworld.pdf +++ /dev/null @@ -1,68 +0,0 @@ -%PDF-1.7 - -1 0 obj % entry point -<< - /Type /Catalog - /Pages 2 0 R ->> -endobj - -2 0 obj -<< - /Type /Pages - /MediaBox [ 0 0 200 200 ] - /Count 1 - /Kids [ 3 0 R ] ->> -endobj - -3 0 obj -<< - /Type /Page - /Parent 2 0 R - /Resources << - /Font << - /F1 4 0 R - >> - >> - /Contents 5 0 R ->> -endobj - -4 0 obj -<< - /Type /Font - /Subtype /Type1 - /BaseFont /Times-Roman ->> -endobj - -5 0 obj % page content -<< - /Length 44 ->> -stream -BT -70 50 TD -/F1 12 Tf -(Hello, world!) Tj -ET -endstream -endobj - -xref -0 6 -0000000000 65535 f -0000000010 00000 n -0000000079 00000 n -0000000173 00000 n -0000000301 00000 n -0000000380 00000 n -trailer -<< - /Size 6 - /Root 1 0 R ->> -startxref -492 -%%EOF \ No newline at end of file diff --git a/examples/create-react-app/public/index.html b/examples/create-react-app/public/index.html deleted file mode 100644 index 330f617fe..000000000 --- a/examples/create-react-app/public/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - PDF.js rendering example with Create React App - - - -
- - - diff --git a/examples/create-react-app/public/manifest.json b/examples/create-react-app/public/manifest.json deleted file mode 100644 index e383893e0..000000000 --- a/examples/create-react-app/public/manifest.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "short_name": "PDf.js React App", - "name": "PDF.js rendering example with Create React App", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/examples/create-react-app/public/robots.txt b/examples/create-react-app/public/robots.txt deleted file mode 100644 index 01b0f9a10..000000000 --- a/examples/create-react-app/public/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * diff --git a/examples/create-react-app/src/app.tsx b/examples/create-react-app/src/app.tsx deleted file mode 100644 index ebdc72157..000000000 --- a/examples/create-react-app/src/app.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react'; - -import Pdf from './pdf'; - -export default function App () { - return ( -
-

PDF.js rendering example with Create React App

- -
- ) -} \ No newline at end of file diff --git a/examples/create-react-app/src/index.css b/examples/create-react-app/src/index.css deleted file mode 100644 index 5b8a80ddd..000000000 --- a/examples/create-react-app/src/index.css +++ /dev/null @@ -1,11 +0,0 @@ -html { - text-align: center; -} - -canvas { - border: 1px dashed; - display: flex; - justify-content: center; - align-items: center; - margin: auto; -} diff --git a/examples/create-react-app/src/index.tsx b/examples/create-react-app/src/index.tsx deleted file mode 100644 index 8429ea8d2..000000000 --- a/examples/create-react-app/src/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import App from './app'; - -import './index.css'; - -ReactDOM.render(, document.getElementById('root')); diff --git a/examples/create-react-app/src/pdf.tsx b/examples/create-react-app/src/pdf.tsx deleted file mode 100644 index 1c09ba6b7..000000000 --- a/examples/create-react-app/src/pdf.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React, { useRef, useEffect } from 'react'; -import PropTypes from 'prop-types'; - -import pdfjs from 'pdfjs-dist'; -import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry'; - -pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker; - -const PdfComponent = ({ src }) => { - const canvasRef = useRef(null) - - useEffect(() => { - const fetchPdf = async () => { - const loadingTask = pdfjs.getDocument(src); - - const pdf = await loadingTask.promise; - - const firstPageNumber = 1; - - const page = await pdf.getPage(firstPageNumber); - - const scale = 1.5; - const viewport = page.getViewport({scale: scale}); - - // Prepare canvas using PDF page dimensions - const canvas = canvasRef.current; - - const context = canvas.getContext('2d'); - canvas.height = viewport.height; - canvas.width = viewport.width; - - // Render PDF page into canvas context - const renderContext = { - canvasContext: context, - viewport: viewport - }; - const renderTask = page.render(renderContext); - - await renderTask.promise; - }; - - fetchPdf(); - }, [src]); - - return ( - - ); -} - -PdfComponent.propTypes = { - src: PropTypes.string -}; - -PdfComponent.defaultProps = { - src: `${process.env.PUBLIC_URL}/helloworld.pdf` -}; - -export default PdfComponent; diff --git a/examples/create-react-app/src/react-app-env.d.ts b/examples/create-react-app/src/react-app-env.d.ts deleted file mode 100644 index 6431bc5fc..000000000 --- a/examples/create-react-app/src/react-app-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/create-react-app/tsconfig.json b/examples/create-react-app/tsconfig.json deleted file mode 100644 index 171592f7e..000000000 --- a/examples/create-react-app/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": false, - "forceConsistentCasingInFileNames": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react" - }, - "include": [ - "src" - ] -}