Skip to content

Commit

Permalink
Releasing v7, upgrading everything and fixing types
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecousins committed Jan 16, 2024
1 parent 8ef7fa7 commit adb5683
Show file tree
Hide file tree
Showing 7 changed files with 1,757 additions and 942 deletions.
13 changes: 7 additions & 6 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
"name": "demo",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@heroicons/react": "2.0.14",
"@heroicons/react": "2.1.1",
"@mikecousins/react-pdf": "workspace:*",
"clsx": "1.2.1",
"clsx": "2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"@vitejs/plugin-react": "3.1.0",
"@vitejs/plugin-react": "4.2.1",
"autoprefixer": "10.4.12",
"postcss": "8.4.21",
"tailwindcss": "3.2.4",
"typescript": "4.8.3",
"vite": "4.1.1"
"tailwindcss": "3.4.1",
"typescript": "5.3.3",
"vite": "5.0.11"
}
}
2 changes: 1 addition & 1 deletion apps/demo/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
Expand Down
19 changes: 15 additions & 4 deletions apps/demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()]
})
plugins: [react()],
build: {
target: "es2022"
},
esbuild: {
target: "es2022"
},
optimizeDeps:{
esbuildOptions: {
target: "es2022",
}
}
});
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"trailingComma": "es5"
},
"devDependencies": {
"prettier": "2.7.1",
"turbo": "1.7.3",
"typescript": "4.8.3"
"prettier": "3.2.2",
"turbo": "1.11.3",
"typescript": "5.3.3"
},
"packageManager": "yarn@3.2.3"
"packageManager": "yarn@3.6.4"
}
39 changes: 24 additions & 15 deletions packages/react-pdf-js/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{
"name": "@mikecousins/react-pdf",
"version": "6.1.1",
"version": "7.0.1",
"description": "Simple React component to wrap up PDF.js. The easiest way to render PDFs in your React app.",
"author": "mikecousins",
"license": "MIT",
"repository": "mikecousins/react-pdf-js",
"repository": {
"type": "git",
"url": "git+https://github.com/mikecousins/react-pdf-js.git"
},
"type": "module",
"files": [
"dist"
],
"main": "./dist/index.mjs",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.js"
}
}
},
"scripts": {
Expand All @@ -37,21 +47,20 @@
]
},
"devDependencies": {
"@testing-library/react": "13.4.0",
"@types/jest": "29.4.0",
"@types/react": "18.0.21",
"@testing-library/react": "14.1.2",
"@types/jest": "29.5.11",
"@types/react": "18.2.48",
"@types/react-dom": "18.0.6",
"@vitejs/plugin-react": "3.1.0",
"@vitejs/plugin-react": "4.2.1",
"jest-canvas-mock": "2.4.0",
"pdfjs-dist": "2.16.105",
"tslib": "2.4.0",
"tsup": "6.5.0",
"typescript": "4.8.3"
"pdfjs-dist": "4.0.379",
"tsup": "8.0.1",
"typescript": "5.3.3"
},
"peerDependencies": {
"pdfjs-dist": "2.16.105",
"pdfjs-dist": "4.0.379",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"bundleDependencies": true
"bundleDependencies": []
}
10 changes: 5 additions & 5 deletions packages/react-pdf-js/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect, useRef } from 'react';
import * as pdfjs from 'pdfjs-dist';
import { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
import { DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
import type { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist';
import type { DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';

function isFunction(value: any): value is Function {
return typeof value === 'function';
Expand Down Expand Up @@ -46,7 +46,7 @@ export const usePdf = ({
page = 1,
cMapUrl,
cMapPacked,
workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`,
workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.mjs`,
withCredentials = false,
}: HookProps): HookReturnValues => {
const [pdfDocument, setPdfDocument] = useState<PDFDocumentProxy>();
Expand Down Expand Up @@ -96,7 +96,7 @@ export const usePdf = ({
}

pdfjs.getDocument(config).promise.then(
loadedPdfDocument => {
(loadedPdfDocument) => {
setPdfDocument(loadedPdfDocument);

if (isFunction(onDocumentLoadSuccessRef.current)) {
Expand Down Expand Up @@ -168,7 +168,7 @@ export const usePdf = ({

if (pdfDocument) {
pdfDocument.getPage(page).then(
loadedPdfPage => {
(loadedPdfPage) => {
setPdfPage(loadedPdfPage);

if (isFunction(onPageLoadSuccessRef.current)) {
Expand Down
Loading

1 comment on commit adb5683

@vercel
Copy link

@vercel vercel bot commented on adb5683 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.