From 932a3a6b6ff652bb4b715d494a6023188abf158e Mon Sep 17 00:00:00 2001 From: hatsu38 Date: Tue, 25 Apr 2023 15:36:42 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Add=20Top=20Page=20f?= =?UTF-8?q?eatures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/home/components/HomeLayout.tsx | 9 ++ src/features/home/index.ts | 1 + src/pages/_app.tsx | 10 +- src/pages/index.tsx | 115 +------------------- tailwind.config.js | 5 +- tsconfig.json | 2 +- 6 files changed, 25 insertions(+), 117 deletions(-) create mode 100644 src/features/home/components/HomeLayout.tsx create mode 100644 src/features/home/index.ts diff --git a/src/features/home/components/HomeLayout.tsx b/src/features/home/components/HomeLayout.tsx new file mode 100644 index 0000000..36b4896 --- /dev/null +++ b/src/features/home/components/HomeLayout.tsx @@ -0,0 +1,9 @@ +export const HomeLayout = () => { + return ( +
+

PDF読み込み

+
+ ) +}; diff --git a/src/features/home/index.ts b/src/features/home/index.ts new file mode 100644 index 0000000..f50b25c --- /dev/null +++ b/src/features/home/index.ts @@ -0,0 +1 @@ +export { HomeLayout } from "./components/HomeLayout"; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 987e3f4..3f8c028 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,6 +1,12 @@ -import "@contracter/src/styles/globals.css"; +import { StrictMode } from "react"; + +import "@contracter/styles/globals.css"; import type { AppProps } from "next/app"; export default function App({ Component, pageProps }: AppProps) { - return ; + return ( + + + + ); } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 75f8068..e98af8c 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,118 +1,7 @@ -import { Inter } from "next/font/google"; -import Image from "next/image"; - -const inter = Inter({ subsets: ["latin"] }); +import { HomeLayout } from "@contracter/features/home"; export default function Home() { return ( -
-
-

- Get started by editing  - src/pages/index.tsx -

-
- - By{" "} - Vercel Logo - -
-
- -
- Next.js Logo -
- -
- -

- Docs{" "} - - -> - -

-

- Find in-depth information about Next.js features and API. -

-
- - -

- Learn{" "} - - -> - -

-

- Learn about Next.js in an interactive course with quizzes! -

-
- - -

- Templates{" "} - - -> - -

-

- Discover and deploy boilerplate example Next.js projects. -

-
- - -

- Deploy{" "} - - -> - -

-

- Instantly deploy your Next.js site to a shareable URL with Vercel. -

-
-
-
+ ); } diff --git a/tailwind.config.js b/tailwind.config.js index 7980350..ec0e579 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,8 +1,11 @@ /** @type {import('tailwindcss').Config} */ module.exports = { + mode: "jit", + important: false, + darkMode: "media", // or 'media' or 'class' content: [ "./src/pages/**/*.{js,ts,jsx,tsx,mdx}", - "./src/components/**/*.{js,ts,jsx,tsx,mdx}", + "./src/features/**/*.{js,ts,jsx,tsx,mdx}", "./src/app/**/*.{js,ts,jsx,tsx,mdx}", ], theme: { diff --git a/tsconfig.json b/tsconfig.json index 69e2445..8107b3e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "jsx": "preserve", "incremental": true, "paths": { - "@contracter/src/*": ["./src/*"] + "@contracter/*": ["./src/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], From a2f15264120795263229b38881884e5f8179ecb5 Mon Sep 17 00:00:00 2001 From: hatsu38 Date: Tue, 25 Apr 2023 16:01:44 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20PDF=E3=81=AE?= =?UTF-8?q?=E6=B7=BB=E4=BB=98=E3=81=BE=E3=81=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 66 +++++++++++++ package.json | 3 + .../DropzoneFileField/DropzoneFileField.tsx | 93 +++++++++++++++++++ .../elements/DropzoneFileField/constants.ts | 5 + src/components/elements/Icon/Icon.tsx | 41 ++++++++ src/components/index.ts | 2 + src/features/home/components/HomeLayout.tsx | 32 ++++++- src/features/home/hooks/index.ts | 1 + src/features/home/hooks/useFile.ts | 40 ++++++++ src/pages/_app.tsx | 15 ++- src/pages/index.tsx | 4 +- src/utils/convertReadableByte.ts | 20 ++++ src/utils/index.ts | 1 + tailwind.config.js | 1 + 14 files changed, 314 insertions(+), 10 deletions(-) create mode 100644 src/components/elements/DropzoneFileField/DropzoneFileField.tsx create mode 100644 src/components/elements/DropzoneFileField/constants.ts create mode 100644 src/components/elements/Icon/Icon.tsx create mode 100644 src/components/index.ts create mode 100644 src/features/home/hooks/index.ts create mode 100644 src/features/home/hooks/useFile.ts create mode 100644 src/utils/convertReadableByte.ts create mode 100644 src/utils/index.ts diff --git a/package-lock.json b/package-lock.json index af54a2a..9aebe74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,9 @@ "postcss": "8.4.23", "react": "18.2.0", "react-dom": "18.2.0", + "react-dropzone": "^14.2.3", + "react-icons": "^4.8.0", + "react-toastify": "^9.1.2", "tailwindcss": "3.3.1", "typescript": "5.0.4" }, @@ -818,6 +821,14 @@ "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz", "integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag==" }, + "node_modules/attr-accept": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.2.tgz", + "integrity": "sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg==", + "engines": { + "node": ">=4" + } + }, "node_modules/autoprefixer": { "version": "10.4.14", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.14.tgz", @@ -1052,6 +1063,14 @@ "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==" }, + "node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1857,6 +1876,17 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-selector": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/file-selector/-/file-selector-0.6.0.tgz", + "integrity": "sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==", + "dependencies": { + "tslib": "^2.4.0" + }, + "engines": { + "node": ">= 12" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -3369,11 +3399,47 @@ "react": "^18.2.0" } }, + "node_modules/react-dropzone": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.2.3.tgz", + "integrity": "sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug==", + "dependencies": { + "attr-accept": "^2.2.2", + "file-selector": "^0.6.0", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">= 10.13" + }, + "peerDependencies": { + "react": ">= 16.8 || 18.0.0" + } + }, + "node_modules/react-icons": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.8.0.tgz", + "integrity": "sha512-N6+kOLcihDiAnj5Czu637waJqSnwlMNROzVZMhfX68V/9bu9qHaMIJC4UdozWoOk57gahFCNHwVvWzm0MTzRjg==", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/react-toastify": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.2.tgz", + "integrity": "sha512-PBfzXO5jMGEtdYR5jxrORlNZZe/EuOkwvwKijMatsZZm8IZwLj01YvobeJYNjFcA6uy6CVrx2fzL9GWbhWPTDA==", + "dependencies": { + "clsx": "^1.1.1" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", diff --git a/package.json b/package.json index de3cf29..2a6be2f 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,9 @@ "postcss": "8.4.23", "react": "18.2.0", "react-dom": "18.2.0", + "react-dropzone": "^14.2.3", + "react-icons": "^4.8.0", + "react-toastify": "^9.1.2", "tailwindcss": "3.3.1", "typescript": "5.0.4" }, diff --git a/src/components/elements/DropzoneFileField/DropzoneFileField.tsx b/src/components/elements/DropzoneFileField/DropzoneFileField.tsx new file mode 100644 index 0000000..5a3b820 --- /dev/null +++ b/src/components/elements/DropzoneFileField/DropzoneFileField.tsx @@ -0,0 +1,93 @@ +import React, { FC, ReactNode } from "react"; +import ReactDropzone, { + FileRejection, + FileError, + ErrorCode, +} from "react-dropzone"; + +import { convertReadableByte } from "@contracter/utils"; + +import { FILE_MAX_BYTE_SIZE, ACCEPT_IMPORT_FILE_TYPES } from "./constants"; + +type PropsType = { + noClick?: boolean; + fileClassName?: string; + multiple?: boolean; + onDropFiles: (acceptedFiles: File[], fileRejections: FileRejection[]) => void; + acceptFileTypes?: Record; + required?: boolean; + maxFileByte?: number; + minFileByte?: number; + children: ReactNode; + readonly?: boolean; + maxFiles?: number; +}; + +export const DropzoneFileField: FC = ({ + noClick = false, + onDropFiles, + acceptFileTypes = ACCEPT_IMPORT_FILE_TYPES, + maxFileByte = FILE_MAX_BYTE_SIZE, + minFileByte = 0, + fileClassName, + readonly = false, + children, + maxFiles, +}: PropsType) => { + const jaErrorMessage = (error: FileError) => { + switch (error.code) { + case ErrorCode.FileInvalidType: + return `アップロードできるファイルの拡張子は ${Object.values( + acceptFileTypes + ).join(",")} です`; + case ErrorCode.FileTooLarge: + return `アップロードできる最大ファイルサイズは${convertReadableByte( + maxFileByte + )}です`; + case ErrorCode.FileTooSmall: + return `アップロードできる最小ファイルサイズは${convertReadableByte( + minFileByte + )}です`; + case ErrorCode.TooManyFiles: + return `アップロードできるファイルは${maxFiles || 1}つです`; + default: + return error.message; + } + }; + + const jaFileRejections = (fileRejections: FileRejection[]) => { + return fileRejections.map((reject) => ({ + file: reject.file, + errors: reject.errors.map((error) => ({ + code: error.code, + message: jaErrorMessage(error), + })), + })); + }; + + return ( +
+ + onDropFiles(acceptedFiles, jaFileRejections(fileRejections)) + } + accept={acceptFileTypes} + multiple={false} + maxSize={maxFileByte} + > + {({ getRootProps, getInputProps, isDragActive }) => ( +
+ + {children} +
+ )} +
+
+ ); +}; diff --git a/src/components/elements/DropzoneFileField/constants.ts b/src/components/elements/DropzoneFileField/constants.ts new file mode 100644 index 0000000..5c8ee87 --- /dev/null +++ b/src/components/elements/DropzoneFileField/constants.ts @@ -0,0 +1,5 @@ +export const FILE_MAX_BYTE_SIZE = 1000 * 1000 * 10; // 10MB + +export const ACCEPT_IMPORT_FILE_TYPES = { + "application/pdf": [".pdf"], +}; diff --git a/src/components/elements/Icon/Icon.tsx b/src/components/elements/Icon/Icon.tsx new file mode 100644 index 0000000..0a050f0 --- /dev/null +++ b/src/components/elements/Icon/Icon.tsx @@ -0,0 +1,41 @@ +import React, { FC } from "react"; +import { AiOutlineClose, AiOutlinePlus } from "react-icons/ai"; +import { HiOutlineEyeOff, HiOutlineEye } from "react-icons/hi"; + +export const ICONS = [ + "hiOutlineEye", + "hiOutlineEyeOff", + "aiOutlinePlus", + "aiOutlineClose", +] as const satisfies readonly string[]; + +export type IconType = (typeof ICONS)[number]; +export type IconColorType = `text-${string}-${number}` | "text-white"; +export type IconSizeType = `${number}rem`; +export type IconPropsType = { + icon: IconType; + className?: string; + size?: IconSizeType; + color?: IconColorType; +}; + +export const Icon: FC = ({ + icon, + size = "2rem", + className = "", + color = "text-gray-400", +}: IconPropsType) => { + const iconProps = { + className: `${className} ${color}`, + size: size, + }; + + const icons = { + hiOutlineEye: , + hiOutlineEyeOff: , + aiOutlinePlus: , + aiOutlineClose: , + }; + + return icons[icon]; +}; diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..5e0fe8f --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,2 @@ +export { DropzoneFileField } from "./elements/DropzoneFileField/DropzoneFileField"; +export { Icon } from "./elements/Icon/Icon"; diff --git a/src/features/home/components/HomeLayout.tsx b/src/features/home/components/HomeLayout.tsx index 36b4896..5717b87 100644 --- a/src/features/home/components/HomeLayout.tsx +++ b/src/features/home/components/HomeLayout.tsx @@ -1,9 +1,31 @@ +import { DropzoneFileField, Icon } from "@contracter/components"; +import { useFile } from "@contracter/features/home/hooks"; + export const HomeLayout = () => { + const { file, handleDropFile } = useFile(); + return ( -
-

PDF読み込み

+
+

契約書PDFを読み込み

+
+ +
+ {file ? ( +

{file.name}

+ ) : ( + <> + +

契約書をインポート

+ + )} +
+
+
- ) + ); }; diff --git a/src/features/home/hooks/index.ts b/src/features/home/hooks/index.ts new file mode 100644 index 0000000..4e61847 --- /dev/null +++ b/src/features/home/hooks/index.ts @@ -0,0 +1 @@ +export { useFile } from "./useFile"; diff --git a/src/features/home/hooks/useFile.ts b/src/features/home/hooks/useFile.ts new file mode 100644 index 0000000..c174d30 --- /dev/null +++ b/src/features/home/hooks/useFile.ts @@ -0,0 +1,40 @@ +import { useState } from "react"; +import { FileRejection } from "react-dropzone"; +import { toast } from "react-toastify"; + +type ReturnType = { + file: File | undefined; + setFile: (value: File | undefined) => void; + fileUrl: string | undefined; + handleDropFile: ( + acceptedFiles: File[], + fileRejections: FileRejection[] + ) => void; +}; + +export const useFile = (): ReturnType => { + const [file, setFile] = useState(); + + const fileUrl = file ? URL.createObjectURL(file) : undefined; + + const handleDropFile = ( + acceptedFiles: File[], + fileRejections: FileRejection[] + ) => { + if (fileRejections.length) { + fileRejections.map(({ file, errors }) => { + if (!errors[0]) return; + toast.error(`${file.name} - ${errors[0].message}`); + }); + return; + } + setFile(acceptedFiles[0]); + }; + + return { + file, + fileUrl, + setFile, + handleDropFile, + }; +}; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 3f8c028..edcd88d 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,11 +1,22 @@ -import { StrictMode } from "react"; +import React, { StrictMode } from "react"; +import { ToastContainer } from "react-toastify"; -import "@contracter/styles/globals.css"; import type { AppProps } from "next/app"; +import "@contracter/styles/globals.css"; +import "react-toastify/dist/ReactToastify.css"; + export default function App({ Component, pageProps }: AppProps) { return ( + ); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index e98af8c..8d27f69 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,7 +1,5 @@ import { HomeLayout } from "@contracter/features/home"; export default function Home() { - return ( - - ); + return ; } diff --git a/src/utils/convertReadableByte.ts b/src/utils/convertReadableByte.ts new file mode 100644 index 0000000..eb4575a --- /dev/null +++ b/src/utils/convertReadableByte.ts @@ -0,0 +1,20 @@ +export const convertReadableByte = (byte: number, fixedNum = 2): string => { + // NOTE: https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string/10420404#answer-20732091 + const fileSizeUnits = [ + "B", + "kB", + "MB", + "GB", + "TB", + "PB", + "EB", + "ZB", + "YB", + ] as const satisfies readonly string[]; + // NOTE: べき乗を計算。1024にpowerOfN乗する + const powerOfN = Math.floor(Math.log(byte) / Math.log(1024)); + const humanReadableFileByte = (byte / Math.pow(1024, powerOfN)).toFixed( + fixedNum + ); + return `${humanReadableFileByte}${fileSizeUnits[powerOfN]}`; +}; diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..7695a8d --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1 @@ +export { convertReadableByte } from "./convertReadableByte"; diff --git a/tailwind.config.js b/tailwind.config.js index ec0e579..c655818 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -5,6 +5,7 @@ module.exports = { darkMode: "media", // or 'media' or 'class' content: [ "./src/pages/**/*.{js,ts,jsx,tsx,mdx}", + "./src/components/**/*.{js,ts,jsx,tsx,mdx}", "./src/features/**/*.{js,ts,jsx,tsx,mdx}", "./src/app/**/*.{js,ts,jsx,tsx,mdx}", ], From 1394d6ac55dd77e18ccdc38ab4a5563ba2301222 Mon Sep 17 00:00:00 2001 From: hatsu38 Date: Tue, 25 Apr 2023 17:22:35 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20PDF=E3=82=92?= =?UTF-8?q?=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=82=93=E3=81=A7=E3=83=86=E3=82=AD?= =?UTF-8?q?=E3=82=B9=E3=83=88=E8=A1=A8=E7=A4=BA=E3=81=BE=E3=81=A7=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 516 ++++++++++++++++++++ package.json | 1 + src/features/home/components/HomeLayout.tsx | 16 +- src/features/home/hooks/index.ts | 1 - src/hooks/index.ts | 2 + src/{features/home => }/hooks/useFile.ts | 0 src/hooks/usePdfLoad.ts | 35 ++ src/styles/globals.css | 24 - 8 files changed, 568 insertions(+), 27 deletions(-) create mode 100644 src/hooks/index.ts rename src/{features/home => }/hooks/useFile.ts (100%) create mode 100644 src/hooks/usePdfLoad.ts diff --git a/package-lock.json b/package-lock.json index 9aebe74..4a0dd91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "eslint": "8.39.0", "eslint-config-next": "13.3.1", "next": "13.3.1", + "pdfjs-dist": "^3.5.141", "postcss": "8.4.23", "react": "18.2.0", "react-dom": "18.2.0", @@ -174,6 +175,26 @@ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, + "node_modules/@mapbox/node-pre-gyp": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz", + "integrity": "sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==", + "optional": true, + "dependencies": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + } + }, "node_modules/@next/env": { "version": "13.3.1", "resolved": "https://registry.npmjs.org/@next/env/-/env-13.3.1.tgz", @@ -641,6 +662,12 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "optional": true + }, "node_modules/acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", @@ -660,6 +687,18 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "optional": true, + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -714,6 +753,25 @@ "node": ">= 8" } }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "optional": true + }, + "node_modules/are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "optional": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/arg": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", @@ -1006,6 +1064,21 @@ } ] }, + "node_modules/canvas": { + "version": "2.11.2", + "resolved": "https://registry.npmjs.org/canvas/-/canvas-2.11.2.tgz", + "integrity": "sha512-ItanGBMrmRV7Py2Z+Xhs7cT+FNt5K0vPL4p9EZ/UX/Mu7hFbkxSjKF2KVtPwX7UYWp7dRKnrTvReflgrItJbdw==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "@mapbox/node-pre-gyp": "^1.0.0", + "nan": "^2.17.0", + "simple-get": "^3.0.3" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -1058,6 +1131,15 @@ "node": ">= 6" } }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "optional": true, + "engines": { + "node": ">=10" + } + }, "node_modules/client-only": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", @@ -1087,6 +1169,15 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "optional": true, + "bin": { + "color-support": "bin.js" + } + }, "node_modules/commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -1100,6 +1191,12 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==", + "optional": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -1150,6 +1247,18 @@ } } }, + "node_modules/decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "optional": true, + "dependencies": { + "mimic-response": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/deep-equal": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.0.tgz", @@ -1205,6 +1314,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", + "optional": true + }, + "node_modules/detect-libc": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", + "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==", + "optional": true, + "engines": { + "node": ">=8" + } + }, "node_modules/didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", @@ -1950,6 +2074,30 @@ "url": "https://www.patreon.com/infusion" } }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "optional": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "optional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1998,6 +2146,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "optional": true, + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/get-intrinsic": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", @@ -2216,6 +2384,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==", + "optional": true + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "optional": true, + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -2397,6 +2584,15 @@ "node": ">=0.10.0" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "optional": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -2734,6 +2930,30 @@ "node": ">=10" } }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "optional": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "optional": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -2754,6 +2974,18 @@ "node": ">=8.6" } }, + "node_modules/mimic-response": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", + "optional": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -2773,6 +3005,52 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "optional": true, + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "optional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "optional": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -2788,6 +3066,12 @@ "thenify-all": "^1.0.0" } }, + "node_modules/nan": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", + "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", + "optional": true + }, "node_modules/nanoid": { "version": "3.3.6", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", @@ -2891,11 +3175,46 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "optional": true, + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/node-releases": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", "integrity": "sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==" }, + "node_modules/nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "optional": true, + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -2912,6 +3231,18 @@ "node": ">=0.10.0" } }, + "node_modules/npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "optional": true, + "dependencies": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -3149,6 +3480,29 @@ "node": ">=8" } }, + "node_modules/path2d-polyfill": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path2d-polyfill/-/path2d-polyfill-2.0.1.tgz", + "integrity": "sha512-ad/3bsalbbWhmBo0D6FZ4RNMwsLsPpL6gnvhuSaU5Vm7b06Kr5ubSltQQ0T7YKsiJQO+g22zJ4dJKNTXIyOXtA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/pdfjs-dist": { + "version": "3.5.141", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.5.141.tgz", + "integrity": "sha512-lYIvyi5grtYOIatsfCifIKwxHeAJ8eHyP22DTdvY4pm0yWVSFQnMafpgCPSw8gaNRDDdcHnBVOkqMsyK8SRxZg==", + "dependencies": { + "path2d-polyfill": "^2.0.1", + "web-streams-polyfill": "^3.2.1" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "canvas": "^2.11.0" + } + }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -3448,6 +3802,20 @@ "pify": "^2.3.0" } }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "optional": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -3549,6 +3917,26 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "optional": true + }, "node_modules/safe-regex-test": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", @@ -3584,6 +3972,12 @@ "node": ">=10" } }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "optional": true + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -3616,6 +4010,43 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "optional": true + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "optional": true + }, + "node_modules/simple-get": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz", + "integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==", + "optional": true, + "dependencies": { + "decompress-response": "^4.2.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -3651,6 +4082,35 @@ "node": ">=10.0.0" } }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "optional": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "optional": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "optional": true + }, "node_modules/string.prototype.matchall": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz", @@ -3889,6 +4349,23 @@ "node": ">=6" } }, + "node_modules/tar": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.13.tgz", + "integrity": "sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==", + "optional": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^4.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -3933,6 +4410,12 @@ "node": ">=8.0" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "optional": true + }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", @@ -4082,6 +4565,30 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, + "node_modules/web-streams-polyfill": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", + "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "optional": true + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "optional": true, + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -4144,6 +4651,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "optional": true, + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, "node_modules/word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", diff --git a/package.json b/package.json index 2a6be2f..22c011e 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "eslint": "8.39.0", "eslint-config-next": "13.3.1", "next": "13.3.1", + "pdfjs-dist": "^3.5.141", "postcss": "8.4.23", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/src/features/home/components/HomeLayout.tsx b/src/features/home/components/HomeLayout.tsx index 5717b87..ed9fb57 100644 --- a/src/features/home/components/HomeLayout.tsx +++ b/src/features/home/components/HomeLayout.tsx @@ -1,8 +1,17 @@ +import { useEffect } from "react"; + import { DropzoneFileField, Icon } from "@contracter/components"; -import { useFile } from "@contracter/features/home/hooks"; +import { useFile, usePdfLoad } from "@contracter/hooks"; export const HomeLayout = () => { - const { file, handleDropFile } = useFile(); + const { file, handleDropFile, fileUrl } = useFile(); + const { pdfText, loadPdfUrl } = usePdfLoad(); + + useEffect(() => { + if (fileUrl) { + loadPdfUrl(fileUrl); + } + }, [file]); return (
@@ -26,6 +35,9 @@ export const HomeLayout = () => { +

+ {pdfText} +

); }; diff --git a/src/features/home/hooks/index.ts b/src/features/home/hooks/index.ts index 4e61847..e69de29 100644 --- a/src/features/home/hooks/index.ts +++ b/src/features/home/hooks/index.ts @@ -1 +0,0 @@ -export { useFile } from "./useFile"; diff --git a/src/hooks/index.ts b/src/hooks/index.ts new file mode 100644 index 0000000..fa36682 --- /dev/null +++ b/src/hooks/index.ts @@ -0,0 +1,2 @@ +export { useFile } from "./useFile"; +export { usePdfLoad } from "./usePdfLoad"; diff --git a/src/features/home/hooks/useFile.ts b/src/hooks/useFile.ts similarity index 100% rename from src/features/home/hooks/useFile.ts rename to src/hooks/useFile.ts diff --git a/src/hooks/usePdfLoad.ts b/src/hooks/usePdfLoad.ts new file mode 100644 index 0000000..986d0ae --- /dev/null +++ b/src/hooks/usePdfLoad.ts @@ -0,0 +1,35 @@ +import { GlobalWorkerOptions, version, getDocument } from "pdfjs-dist"; +import { useState } from "react"; + +type ReturnType = { + loadPdfUrl: (pdfUrl: string) => void; + pdfText: string; +}; + +export const usePdfLoad = (): ReturnType => { + GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${version}/pdf.worker.min.js`; + + const [pdfText, setPdfText] = useState(""); + + const loadPdfUrl = (pdfUrl: string) => { + const loadingTask = getDocument(pdfUrl); + loadingTask.promise.then((pdf) => { + const numPages = pdf.numPages; + [...Array(numPages)].map((_, index) => { + pdf.getPage(index + 1).then((page) => { + page.getTextContent().then((textContent) => { + const text = textContent.items.map((item) => + "str" in item ? item.str : "" + ); + setPdfText((prev) => prev + text.join("\n")); + }); + }); + }); + }); + }; + + return { + loadPdfUrl, + pdfText, + }; +}; diff --git a/src/styles/globals.css b/src/styles/globals.css index fd81e88..b5c61c9 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -1,27 +1,3 @@ @tailwind base; @tailwind components; @tailwind utilities; - -:root { - --foreground-rgb: 0, 0, 0; - --background-start-rgb: 214, 219, 220; - --background-end-rgb: 255, 255, 255; -} - -@media (prefers-color-scheme: dark) { - :root { - --foreground-rgb: 255, 255, 255; - --background-start-rgb: 0, 0, 0; - --background-end-rgb: 0, 0, 0; - } -} - -body { - color: rgb(var(--foreground-rgb)); - background: linear-gradient( - to bottom, - transparent, - rgb(var(--background-end-rgb)) - ) - rgb(var(--background-start-rgb)); -} From 8af141f7f208e9f1dc51b82e550354976b5c455f Mon Sep 17 00:00:00 2001 From: hatsu38 Date: Tue, 25 Apr 2023 17:42:24 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20format:fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 5 ----- package-lock.json | 9 +-------- package.json | 3 +-- src/features/home/components/HomeLayout.tsx | 3 ++- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9e2d673..9720d2f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -82,11 +82,6 @@ "group": "external", "position": "after" }, - { - "pattern": "{@contracter/src/models/**,@contracter/src/models}", - "group": "external", - "position": "after" - }, { "pattern": "{@contracter/src/hooks/**,@contracter/src/hooks}", "group": "internal", diff --git a/package-lock.json b/package-lock.json index 4a0dd91..e37d86b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,8 +30,7 @@ "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-jsx-a11y": "^6.7.1", - "prettier": "^2.8.8", - "typescript-eslint": "^0.0.1-alpha.0" + "prettier": "^2.8.8" } }, "node_modules/@babel/runtime": { @@ -4503,12 +4502,6 @@ "node": ">=12.20" } }, - "node_modules/typescript-eslint": { - "version": "0.0.1-alpha.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-0.0.1-alpha.0.tgz", - "integrity": "sha512-1hNKM37dAWML/2ltRXupOq2uqcdRQyDFphl+341NTPXFLLLiDhErXx8VtaSLh3xP7SyHZdcCgpt9boYYVb3fQg==", - "dev": true - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", diff --git a/package.json b/package.json index 22c011e..f4da41d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-jsx-a11y": "^6.7.1", - "prettier": "^2.8.8", - "typescript-eslint": "^0.0.1-alpha.0" + "prettier": "^2.8.8" } } diff --git a/src/features/home/components/HomeLayout.tsx b/src/features/home/components/HomeLayout.tsx index ed9fb57..8f3b42b 100644 --- a/src/features/home/components/HomeLayout.tsx +++ b/src/features/home/components/HomeLayout.tsx @@ -11,7 +11,8 @@ export const HomeLayout = () => { if (fileUrl) { loadPdfUrl(fileUrl); } - }, [file]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [file, loadPdfUrl]); return (