From 96fd1cf73ba0ad18158e9ff99f9dca9944ea1ff4 Mon Sep 17 00:00:00 2001 From: Daniel <50052685+schroda@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:40:37 +0100 Subject: [PATCH] remove manually created typing d ts file (#249) * Rename file ".d.ts" files are files that are automatically generated during compilation (in case option is set) and shouldn't be created manually. * Export types and interfaces * Add missing imports --- src/components/ExtensionCard.tsx | 1 + src/components/MangaCard.tsx | 1 + src/components/MangaGrid.tsx | 1 + src/components/SourceCard.tsx | 1 + .../context/LibraryOptionsContext.tsx | 1 + src/components/context/NavbarContext.tsx | 1 + src/components/library/LibraryMangaGrid.tsx | 1 + .../library/LibraryOptionsPanel.tsx | 1 + .../library/LibraryOptionsProvider.tsx | 1 + src/components/library/UpdateChecker.tsx | 1 + src/components/manga/ChapterCard.tsx | 1 + src/components/manga/ChapterList.tsx | 1 + src/components/manga/ChapterOptions.tsx | 1 + src/components/manga/ChaptersToolbarMenu.tsx | 1 + src/components/manga/MangaDetails.tsx | 1 + src/components/manga/MangaToolbarMenu.tsx | 1 + src/components/manga/ResumeFAB.tsx | 1 + src/components/manga/util.tsx | 1 + .../molecules/DownloadStateIndicator.tsx | 1 + src/components/navbar/DefaultNavBar.tsx | 1 + .../navbar/NavBarContextProvider.tsx | 1 + src/components/navbar/ReaderNavBar.tsx | 1 + .../navbar/action/CategorySelect.tsx | 1 + .../navbar/navigation/DesktopSideBar.tsx | 1 + .../navbar/navigation/MobileBottomBar.tsx | 1 + src/components/reader/DoublePage.tsx | 1 + src/components/reader/Page.tsx | 1 + src/components/reader/PageNumber.tsx | 1 + .../reader/ReaderSettingsOptions.tsx | 1 + .../reader/pager/DoublePagedPager.tsx | 1 + .../reader/pager/HorizontalPager.tsx | 1 + src/components/reader/pager/PagedPager.tsx | 1 + src/components/reader/pager/VerticalPager.tsx | 1 + src/components/source/SourceMangaGrid.tsx | 1 + src/components/source/SourceOptions.tsx | 1 + src/components/source/filters/GroupFilter.tsx | 1 + src/components/source/filters/SortFilter.tsx | 1 + .../EditTextPreference.tsx | 1 + .../sourceConfiguration/ListPreference.tsx | 1 + .../MultiSelectListPreference.tsx | 1 + .../TwoStatePreference.tsx | 1 + src/screens/DownloadQueue.tsx | 1 + src/screens/Extensions.tsx | 1 + src/screens/Library.tsx | 1 + src/screens/Manga.tsx | 1 + src/screens/Reader.tsx | 1 + src/screens/SearchAll.tsx | 1 + src/screens/SourceConfigure.tsx | 1 + src/screens/SourceMangas.tsx | 1 + src/screens/Sources.tsx | 1 + src/screens/Updates.tsx | 1 + src/screens/settings/About.tsx | 1 + src/screens/settings/Categories.tsx | 1 + .../settings/DefaultReaderSettings.tsx | 1 + src/{typings.d.ts => typings.ts} | 97 ++++++++++--------- src/util/metadata.ts | 12 +++ src/util/readerSettings.ts | 1 + 57 files changed, 117 insertions(+), 47 deletions(-) rename src/{typings.d.ts => typings.ts} (72%) diff --git a/src/components/ExtensionCard.tsx b/src/components/ExtensionCard.tsx index b8212ab2..159abd2e 100644 --- a/src/components/ExtensionCard.tsx +++ b/src/components/ExtensionCard.tsx @@ -14,6 +14,7 @@ import Typography from '@mui/material/Typography'; import client from 'util/client'; import useLocalStorage from 'util/useLocalStorage'; import { Box } from '@mui/system'; +import { IExtension } from 'typings'; interface IProps { extension: IExtension; diff --git a/src/components/MangaCard.tsx b/src/components/MangaCard.tsx index c78aab9b..9a18237b 100644 --- a/src/components/MangaCard.tsx +++ b/src/components/MangaCard.tsx @@ -16,6 +16,7 @@ import SpinnerImage from 'components/util/SpinnerImage'; import { Box, styled } from '@mui/system'; import { GridLayout, useLibraryOptionsContext } from 'components/context/LibraryOptionsContext'; import { BACK } from 'util/useBackTo'; +import { IMangaCard } from 'typings'; const BottomGradient = styled('div')({ position: 'absolute', diff --git a/src/components/MangaGrid.tsx b/src/components/MangaGrid.tsx index 25b52ae6..32436c09 100644 --- a/src/components/MangaGrid.tsx +++ b/src/components/MangaGrid.tsx @@ -13,6 +13,7 @@ import { Typography } from '@mui/material'; import { Box } from '@mui/system'; import MangaCard from 'components/MangaCard'; import { GridLayout } from 'components/context/LibraryOptionsContext'; +import { IMangaCard } from 'typings'; export interface IMangaGridProps { mangas: IMangaCard[]; diff --git a/src/components/SourceCard.tsx b/src/components/SourceCard.tsx index 0edbb269..36f53e60 100644 --- a/src/components/SourceCard.tsx +++ b/src/components/SourceCard.tsx @@ -16,6 +16,7 @@ import React from 'react'; import { Link, useHistory } from 'react-router-dom'; import { langCodeToName } from 'util/language'; import useLocalStorage from 'util/useLocalStorage'; +import { ISource } from 'typings'; const MobileWidthButtons = styled('div')(({ theme }) => ({ display: 'flex', diff --git a/src/components/context/LibraryOptionsContext.tsx b/src/components/context/LibraryOptionsContext.tsx index e8c4da5d..a6d80371 100644 --- a/src/components/context/LibraryOptionsContext.tsx +++ b/src/components/context/LibraryOptionsContext.tsx @@ -6,6 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import React, { useContext } from 'react'; +import { LibraryOptions } from 'typings'; type ContextType = { options: LibraryOptions; diff --git a/src/components/context/NavbarContext.tsx b/src/components/context/NavbarContext.tsx index 6bc3f2c9..fd1701f1 100644 --- a/src/components/context/NavbarContext.tsx +++ b/src/components/context/NavbarContext.tsx @@ -6,6 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import React, { useContext, useEffect } from 'react'; +import { INavbarOverride } from 'typings'; type ContextType = { // Default back button url diff --git a/src/components/library/LibraryMangaGrid.tsx b/src/components/library/LibraryMangaGrid.tsx index e43f88da..6748cee3 100644 --- a/src/components/library/LibraryMangaGrid.tsx +++ b/src/components/library/LibraryMangaGrid.tsx @@ -11,6 +11,7 @@ import MangaGrid from 'components/MangaGrid'; import { useLibraryOptionsContext } from 'components/context/LibraryOptionsContext'; import { StringParam, useQueryParam } from 'use-query-params'; import { useMediaQuery, useTheme } from '@mui/material'; +import { IMangaCard, LibrarySortMode, NullAndUndefined } from 'typings'; const FILTERED_OUT_MESSAGE = 'There are no Manga matching this filter'; diff --git a/src/components/library/LibraryOptionsPanel.tsx b/src/components/library/LibraryOptionsPanel.tsx index 3375a3fa..a985cbd1 100644 --- a/src/components/library/LibraryOptionsPanel.tsx +++ b/src/components/library/LibraryOptionsPanel.tsx @@ -13,6 +13,7 @@ import ThreeStateCheckboxInput from 'components/atoms/ThreeStateCheckboxInput'; import { GridLayout, useLibraryOptionsContext } from 'components/context/LibraryOptionsContext'; import OptionsTabs from 'components/molecules/OptionsTabs'; import React from 'react'; +import { LibraryOptions, LibrarySortMode } from 'typings'; const TITLES = { filter: 'Filter', diff --git a/src/components/library/LibraryOptionsProvider.tsx b/src/components/library/LibraryOptionsProvider.tsx index 41ce1431..86b99d1f 100644 --- a/src/components/library/LibraryOptionsProvider.tsx +++ b/src/components/library/LibraryOptionsProvider.tsx @@ -8,6 +8,7 @@ import LibraryOptionsContext, { DefaultLibraryOptions } from 'components/context/LibraryOptionsContext'; import React from 'react'; import useLocalStorage from 'util/useLocalStorage'; +import { LibraryOptions } from 'typings'; interface IProps { children: React.ReactNode; diff --git a/src/components/library/UpdateChecker.tsx b/src/components/library/UpdateChecker.tsx index 135e137e..6f82d120 100644 --- a/src/components/library/UpdateChecker.tsx +++ b/src/components/library/UpdateChecker.tsx @@ -6,6 +6,7 @@ import { Box } from '@mui/system'; import Typography from '@mui/material/Typography'; import client from 'util/client'; import makeToast from 'components/util/Toast'; +import { IUpdateStatus } from 'typings'; interface IProgressProps { progress: number; diff --git a/src/components/manga/ChapterCard.tsx b/src/components/manga/ChapterCard.tsx index 72255cd7..eb33413d 100644 --- a/src/components/manga/ChapterCard.tsx +++ b/src/components/manga/ChapterCard.tsx @@ -29,6 +29,7 @@ import { Link } from 'react-router-dom'; import client from 'util/client'; import { BACK } from 'util/useBackTo'; import { getUploadDateString } from 'util/date'; +import { IChapter, IDownloadChapter } from 'typings'; interface IProps { chapter: IChapter; diff --git a/src/components/manga/ChapterList.tsx b/src/components/manga/ChapterList.tsx index 9a2d8287..00373df4 100644 --- a/src/components/manga/ChapterList.tsx +++ b/src/components/manga/ChapterList.tsx @@ -20,6 +20,7 @@ import { Virtuoso } from 'react-virtuoso'; import client, { useQuery } from 'util/client'; import ChaptersToolbarMenu from 'components/manga/ChaptersToolbarMenu'; import SelectionFAB from 'components/manga/SelectionFAB'; +import { BatchChaptersChange, IChapter, IDownloadChapter, IQueue } from 'typings'; const StyledVirtuoso = styled(Virtuoso)(({ theme }) => ({ listStyle: 'none', diff --git a/src/components/manga/ChapterOptions.tsx b/src/components/manga/ChapterOptions.tsx index bb6166d9..748c4730 100644 --- a/src/components/manga/ChapterOptions.tsx +++ b/src/components/manga/ChapterOptions.tsx @@ -12,6 +12,7 @@ import ThreeStateCheckboxInput from 'components/atoms/ThreeStateCheckboxInput'; import OptionsTabs from 'components/molecules/OptionsTabs'; import React from 'react'; import { SORT_OPTIONS } from 'components/manga/util'; +import { ChapterListOptions, ChapterOptionsReducerAction } from 'typings'; interface IProps { open: boolean; diff --git a/src/components/manga/ChaptersToolbarMenu.tsx b/src/components/manga/ChaptersToolbarMenu.tsx index 6798ba3e..3517129d 100644 --- a/src/components/manga/ChaptersToolbarMenu.tsx +++ b/src/components/manga/ChaptersToolbarMenu.tsx @@ -10,6 +10,7 @@ import { IconButton } from '@mui/material'; import * as React from 'react'; import ChapterOptions from 'components/manga/ChapterOptions'; import { isFilterActive } from 'components/manga/util'; +import { ChapterListOptions, ChapterOptionsReducerAction } from 'typings'; interface IProps { options: ChapterListOptions; diff --git a/src/components/manga/MangaDetails.tsx b/src/components/manga/MangaDetails.tsx index e0f28484..2d3474da 100644 --- a/src/components/manga/MangaDetails.tsx +++ b/src/components/manga/MangaDetails.tsx @@ -16,6 +16,7 @@ import React from 'react'; import { mutate } from 'swr'; import client from 'util/client'; import useLocalStorage from 'util/useLocalStorage'; +import { IManga, ISource } from 'typings'; const useStyles = (inLibrary: boolean) => makeStyles((theme: Theme) => ({ diff --git a/src/components/manga/MangaToolbarMenu.tsx b/src/components/manga/MangaToolbarMenu.tsx index 55a71512..608ee1f6 100644 --- a/src/components/manga/MangaToolbarMenu.tsx +++ b/src/components/manga/MangaToolbarMenu.tsx @@ -20,6 +20,7 @@ import { } from '@mui/material'; import CategorySelect from 'components/navbar/action/CategorySelect'; import React, { useState } from 'react'; +import { IManga } from 'typings'; interface IProps { manga: IManga; diff --git a/src/components/manga/ResumeFAB.tsx b/src/components/manga/ResumeFAB.tsx index 72016a06..75899e06 100644 --- a/src/components/manga/ResumeFAB.tsx +++ b/src/components/manga/ResumeFAB.tsx @@ -10,6 +10,7 @@ import { Fab } from '@mui/material'; import { Link } from 'react-router-dom'; import { PlayArrow } from '@mui/icons-material'; import { BACK } from 'util/useBackTo'; +import { IChapter } from 'typings'; interface ResumeFABProps { chapter: IChapter; diff --git a/src/components/manga/util.tsx b/src/components/manga/util.tsx index 0f2dfdc8..d1ee8f56 100644 --- a/src/components/manga/util.tsx +++ b/src/components/manga/util.tsx @@ -6,6 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { useReducerLocalStorage } from 'util/useLocalStorage'; +import { ChapterListOptions, ChapterOptionsReducerAction, ChapterSortMode, IChapter, NullAndUndefined } from 'typings'; const defaultChapterOptions: ChapterListOptions = { active: false, diff --git a/src/components/molecules/DownloadStateIndicator.tsx b/src/components/molecules/DownloadStateIndicator.tsx index 6f040b5f..082df821 100644 --- a/src/components/molecules/DownloadStateIndicator.tsx +++ b/src/components/molecules/DownloadStateIndicator.tsx @@ -10,6 +10,7 @@ import { CircularProgress } from '@mui/material'; import Typography from '@mui/material/Typography'; import { Box } from '@mui/system'; import React from 'react'; +import { IDownloadChapter } from 'typings'; interface DownloadStateIndicatorProps { download: IDownloadChapter; diff --git a/src/components/navbar/DefaultNavBar.tsx b/src/components/navbar/DefaultNavBar.tsx index fc7f6c2b..1e8c8c46 100644 --- a/src/components/navbar/DefaultNavBar.tsx +++ b/src/components/navbar/DefaultNavBar.tsx @@ -33,6 +33,7 @@ import DesktopSideBar from 'components/navbar/navigation/DesktopSideBar'; import MobileBottomBar from 'components/navbar/navigation/MobileBottomBar'; // import { useTranslation } from 'react-i18next'; import { t } from 'i18next'; +import { NavbarItem } from 'typings'; const navbarItems: Array = [ { diff --git a/src/components/navbar/NavBarContextProvider.tsx b/src/components/navbar/NavBarContextProvider.tsx index 7443a85e..eca56750 100644 --- a/src/components/navbar/NavBarContextProvider.tsx +++ b/src/components/navbar/NavBarContextProvider.tsx @@ -7,6 +7,7 @@ import React, { useState } from 'react'; import NavBarContext from 'components/context/NavbarContext'; +import { INavbarOverride } from 'typings'; interface IProps { children: React.ReactNode; diff --git a/src/components/navbar/ReaderNavBar.tsx b/src/components/navbar/ReaderNavBar.tsx index 80c6b0f9..3e4705d7 100644 --- a/src/components/navbar/ReaderNavBar.tsx +++ b/src/components/navbar/ReaderNavBar.tsx @@ -25,6 +25,7 @@ import Collapse from '@mui/material/Collapse'; import { styled } from '@mui/system'; import useBackTo from 'util/useBackTo'; import ReaderSettingsOptions from 'components/reader/ReaderSettingsOptions'; +import { IChapter, IManga, IMangaCard, IReaderSettings } from 'typings'; const Root = styled('div')(({ theme }) => ({ top: 0, diff --git a/src/components/navbar/action/CategorySelect.tsx b/src/components/navbar/action/CategorySelect.tsx index 78233f30..69f13265 100644 --- a/src/components/navbar/action/CategorySelect.tsx +++ b/src/components/navbar/action/CategorySelect.tsx @@ -15,6 +15,7 @@ import Checkbox from '@mui/material/Checkbox'; import FormControlLabel from '@mui/material/FormControlLabel'; import FormGroup from '@mui/material/FormGroup'; import client, { useQuery } from 'util/client'; +import { ICategory } from 'typings'; interface IProps { open: boolean; diff --git a/src/components/navbar/navigation/DesktopSideBar.tsx b/src/components/navbar/navigation/DesktopSideBar.tsx index db6c218a..e9ad004a 100644 --- a/src/components/navbar/navigation/DesktopSideBar.tsx +++ b/src/components/navbar/navigation/DesktopSideBar.tsx @@ -10,6 +10,7 @@ import { ListItem, ListItemIcon, Tooltip } from '@mui/material'; import { Link, useLocation } from 'react-router-dom'; import { styled } from '@mui/system'; import { useTheme } from '@mui/material/styles'; +import { NavbarItem } from 'typings'; const SideNavBarContainer = styled('div')(({ theme }) => ({ height: '100vh', diff --git a/src/components/navbar/navigation/MobileBottomBar.tsx b/src/components/navbar/navigation/MobileBottomBar.tsx index 865d34b6..d6b5bbd9 100644 --- a/src/components/navbar/navigation/MobileBottomBar.tsx +++ b/src/components/navbar/navigation/MobileBottomBar.tsx @@ -10,6 +10,7 @@ import { ListItem } from '@mui/material'; import { styled, Box } from '@mui/system'; import { Link as RRDLink, useLocation } from 'react-router-dom'; import { useTheme } from '@mui/material/styles'; +import { NavbarItem } from 'typings'; const BottomNavContainer = styled('div')(({ theme }) => ({ bottom: 0, diff --git a/src/components/reader/DoublePage.tsx b/src/components/reader/DoublePage.tsx index 25cad07b..75e9c6a5 100644 --- a/src/components/reader/DoublePage.tsx +++ b/src/components/reader/DoublePage.tsx @@ -7,6 +7,7 @@ import React from 'react'; import { Box, styled } from '@mui/system'; +import { IReaderSettings } from 'typings'; const Image = styled('img')({ marginBottom: 0, diff --git a/src/components/reader/Page.tsx b/src/components/reader/Page.tsx index d7cbe9dc..4ea43bda 100644 --- a/src/components/reader/Page.tsx +++ b/src/components/reader/Page.tsx @@ -9,6 +9,7 @@ import React, { useRef } from 'react'; import SpinnerImage from 'components/util/SpinnerImage'; import useLocalStorage from 'util/useLocalStorage'; import Box from '@mui/system/Box'; +import { IReaderSettings } from 'typings'; function imageStyle(settings: IReaderSettings): any { const [dimensions, setDimensions] = React.useState({ diff --git a/src/components/reader/PageNumber.tsx b/src/components/reader/PageNumber.tsx index c5fabbb9..25b20772 100644 --- a/src/components/reader/PageNumber.tsx +++ b/src/components/reader/PageNumber.tsx @@ -7,6 +7,7 @@ import React from 'react'; import { Box } from '@mui/system'; +import { IReaderSettings } from 'typings'; interface IProps { settings: IReaderSettings; diff --git a/src/components/reader/ReaderSettingsOptions.tsx b/src/components/reader/ReaderSettingsOptions.tsx index eab9da81..0cb53051 100644 --- a/src/components/reader/ReaderSettingsOptions.tsx +++ b/src/components/reader/ReaderSettingsOptions.tsx @@ -11,6 +11,7 @@ import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction'; import Select from '@mui/material/Select'; import MenuItem from '@mui/material/MenuItem'; import React from 'react'; +import { IReaderSettings } from 'typings'; interface IProps extends IReaderSettings { setSettingValue: (key: keyof IReaderSettings, value: string | boolean) => void; diff --git a/src/components/reader/pager/DoublePagedPager.tsx b/src/components/reader/pager/DoublePagedPager.tsx index e4faeeed..01a33b43 100644 --- a/src/components/reader/pager/DoublePagedPager.tsx +++ b/src/components/reader/pager/DoublePagedPager.tsx @@ -10,6 +10,7 @@ import ReactDOM from 'react-dom'; import { Box } from '@mui/system'; import Page from 'components/reader/Page'; import DoublePage from 'components/reader/DoublePage'; +import { IReaderProps } from 'typings'; const isSpreadPage = (image: HTMLImageElement): boolean => { const aspectRatio = image.height / image.width; diff --git a/src/components/reader/pager/HorizontalPager.tsx b/src/components/reader/pager/HorizontalPager.tsx index d46b5499..f878123d 100644 --- a/src/components/reader/pager/HorizontalPager.tsx +++ b/src/components/reader/pager/HorizontalPager.tsx @@ -8,6 +8,7 @@ import React, { useEffect, useRef } from 'react'; import { Box } from '@mui/system'; import Page from 'components/reader/Page'; +import { IReaderProps } from 'typings'; const findCurrentPageIndex = (wrapper: HTMLDivElement): number => { for (let i = 0; i < wrapper.children.length; i++) { diff --git a/src/components/reader/pager/PagedPager.tsx b/src/components/reader/pager/PagedPager.tsx index ba74e218..189a0781 100644 --- a/src/components/reader/pager/PagedPager.tsx +++ b/src/components/reader/pager/PagedPager.tsx @@ -8,6 +8,7 @@ import React, { useEffect, useRef } from 'react'; import { Box } from '@mui/system'; import Page from 'components/reader/Page'; +import { IReaderProps } from 'typings'; export default function PagedReader(props: IReaderProps) { const { pages, settings, setCurPage, initialPage, curPage, nextChapter, prevChapter } = props; diff --git a/src/components/reader/pager/VerticalPager.tsx b/src/components/reader/pager/VerticalPager.tsx index 2be272a9..422c7c2a 100644 --- a/src/components/reader/pager/VerticalPager.tsx +++ b/src/components/reader/pager/VerticalPager.tsx @@ -8,6 +8,7 @@ import React, { useCallback, useEffect, useRef } from 'react'; import { Box } from '@mui/system'; import Page from 'components/reader/Page'; +import { IReaderProps } from 'typings'; const findCurrentPageIndex = (wrapper: HTMLDivElement): number => { for (let i = 0; i < wrapper.children.length; i++) { diff --git a/src/components/source/SourceMangaGrid.tsx b/src/components/source/SourceMangaGrid.tsx index c6ecd03f..6e579645 100644 --- a/src/components/source/SourceMangaGrid.tsx +++ b/src/components/source/SourceMangaGrid.tsx @@ -8,6 +8,7 @@ import React from 'react'; import MangaGrid, { IMangaGridProps } from 'components/MangaGrid'; +import { IMangaCard } from 'typings'; const FILTERED_OUT_MESSAGE = 'There are no Manga matching this filter'; diff --git a/src/components/source/SourceOptions.tsx b/src/components/source/SourceOptions.tsx index 6a68d58e..cab02620 100644 --- a/src/components/source/SourceOptions.tsx +++ b/src/components/source/SourceOptions.tsx @@ -21,6 +21,7 @@ import TriStateFilter from 'components/source/filters/TriStateFilter'; // eslint-disable-next-line import/no-cycle import GroupFilter from 'components/source/filters/GroupFilter'; import SeperatorFilter from 'components/source/filters/SeparatorFilter'; +import { ISourceFilters, IState } from 'typings'; interface IFilters { sourceFilter: ISourceFilters[]; diff --git a/src/components/source/filters/GroupFilter.tsx b/src/components/source/filters/GroupFilter.tsx index 69f2389e..cb7c76d1 100644 --- a/src/components/source/filters/GroupFilter.tsx +++ b/src/components/source/filters/GroupFilter.tsx @@ -11,6 +11,7 @@ import { Box } from '@mui/system'; import React from 'react'; // eslint-disable-next-line import/no-cycle import { Options } from 'components/source/SourceOptions'; +import { ISourceFilters } from 'typings'; interface Props { state: ISourceFilters[]; diff --git a/src/components/source/filters/SortFilter.tsx b/src/components/source/filters/SortFilter.tsx index 2dee73b7..8e3b3ac4 100644 --- a/src/components/source/filters/SortFilter.tsx +++ b/src/components/source/filters/SortFilter.tsx @@ -10,6 +10,7 @@ import { Collapse, ListItemButton, ListItemText, Stack } from '@mui/material'; import { Box } from '@mui/system'; import SortRadioInput from 'components/atoms/SortRadioInput'; import React from 'react'; +import { IState } from 'typings'; interface Props { values: any; diff --git a/src/components/sourceConfiguration/EditTextPreference.tsx b/src/components/sourceConfiguration/EditTextPreference.tsx index 900efe61..168ea2b4 100644 --- a/src/components/sourceConfiguration/EditTextPreference.tsx +++ b/src/components/sourceConfiguration/EditTextPreference.tsx @@ -15,6 +15,7 @@ import DialogContentText from '@mui/material/DialogContentText'; import DialogActions from '@mui/material/DialogActions'; import TextField from '@mui/material/TextField'; import Button from '@mui/material/Button'; +import { EditTextPreferenceProps } from 'typings'; export default function EditTextPreference(props: EditTextPreferenceProps) { const { title, summary, dialogTitle, dialogMessage, currentValue, updateValue } = props; diff --git a/src/components/sourceConfiguration/ListPreference.tsx b/src/components/sourceConfiguration/ListPreference.tsx index ee21d774..847c4dd9 100644 --- a/src/components/sourceConfiguration/ListPreference.tsx +++ b/src/components/sourceConfiguration/ListPreference.tsx @@ -16,6 +16,7 @@ import RadioGroup from '@mui/material/RadioGroup'; import Radio from '@mui/material/Radio'; import FormControlLabel from '@mui/material/FormControlLabel'; import Button from '@mui/material/Button'; +import { ListPreferenceProps } from 'typings'; interface IListDialogProps { value: string; diff --git a/src/components/sourceConfiguration/MultiSelectListPreference.tsx b/src/components/sourceConfiguration/MultiSelectListPreference.tsx index 846b46f1..18f97fd8 100644 --- a/src/components/sourceConfiguration/MultiSelectListPreference.tsx +++ b/src/components/sourceConfiguration/MultiSelectListPreference.tsx @@ -17,6 +17,7 @@ import Checkbox from '@mui/material/Checkbox'; import FormControlLabel from '@mui/material/FormControlLabel'; import Button from '@mui/material/Button'; import cloneObject from 'util/cloneObject'; +import { MultiSelectListPreferenceProps } from 'typings'; interface IListDialogProps { selectedValues: string[]; diff --git a/src/components/sourceConfiguration/TwoStatePreference.tsx b/src/components/sourceConfiguration/TwoStatePreference.tsx index 8dc64bd1..f4898105 100644 --- a/src/components/sourceConfiguration/TwoStatePreference.tsx +++ b/src/components/sourceConfiguration/TwoStatePreference.tsx @@ -11,6 +11,7 @@ import ListItemText from '@mui/material/ListItemText'; import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction'; import Switch from '@mui/material/Switch'; import Checkbox from '@mui/material/Checkbox'; +import { CheckBoxPreferenceProps, SwitchPreferenceCompatProps, TwoStatePreferenceProps } from 'typings'; function getTwoStateType(type: 'Checkbox' | 'Switch') { if (type === 'Switch') { diff --git a/src/screens/DownloadQueue.tsx b/src/screens/DownloadQueue.tsx index a062fadb..762d5de5 100644 --- a/src/screens/DownloadQueue.tsx +++ b/src/screens/DownloadQueue.tsx @@ -27,6 +27,7 @@ import { NavbarToolbar } from 'components/navbar/DefaultNavBar'; import { Link } from 'react-router-dom'; import { BACK } from 'util/useBackTo'; import { useTranslation } from 'react-i18next'; +import { IChapter, IQueue } from 'typings'; const initialQueue = { status: 'Stopped', diff --git a/src/screens/Extensions.tsx b/src/screens/Extensions.tsx index 52d2147f..9dc56683 100644 --- a/src/screens/Extensions.tsx +++ b/src/screens/Extensions.tsx @@ -21,6 +21,7 @@ import AppbarSearch from 'components/util/AppbarSearch'; import { useQueryParam, StringParam } from 'use-query-params'; import { Virtuoso } from 'react-virtuoso'; import { Typography, useMediaQuery, useTheme } from '@mui/material'; +import { IExtension } from 'typings'; const LANGUAGE = 0; const EXTENSIONS = 1; diff --git a/src/screens/Library.tsx b/src/screens/Library.tsx index 1656f369..caccb26e 100644 --- a/src/screens/Library.tsx +++ b/src/screens/Library.tsx @@ -18,6 +18,7 @@ import { useQueryParam, NumberParam } from 'use-query-params'; import { useQuery } from 'util/client'; import UpdateChecker from 'components/library/UpdateChecker'; import { useTranslation } from 'react-i18next'; +import { ICategory, IManga } from 'typings'; export default function Library() { const { t } = useTranslation(); diff --git a/src/screens/Manga.tsx b/src/screens/Manga.tsx index 21b7dd42..d6e298e9 100644 --- a/src/screens/Manga.tsx +++ b/src/screens/Manga.tsx @@ -19,6 +19,7 @@ import LoadingPlaceholder from 'components/util/LoadingPlaceholder'; import React, { useContext, useEffect, useRef } from 'react'; import { useParams } from 'react-router-dom'; import { useQuery } from 'util/client'; +import { IManga } from 'typings'; const AUTOFETCH_AGE = 60 * 60 * 24; // 24 hours diff --git a/src/screens/Reader.tsx b/src/screens/Reader.tsx index 3ed165a9..fe40138e 100644 --- a/src/screens/Reader.tsx +++ b/src/screens/Reader.tsx @@ -25,6 +25,7 @@ import { useDefaultReaderSettings, } from 'util/readerSettings'; import makeToast from 'components/util/Toast'; +import { IChapter, IManga, IMangaCard, IPartialChapter, IReaderSettings, ReaderType } from 'typings'; const getReaderComponent = (readerType: ReaderType) => { switch (readerType) { diff --git a/src/screens/SearchAll.tsx b/src/screens/SearchAll.tsx index 34fa4b19..f20815f0 100644 --- a/src/screens/SearchAll.tsx +++ b/src/screens/SearchAll.tsx @@ -18,6 +18,7 @@ import { StringParam, useQueryParam } from 'use-query-params'; import client from 'util/client'; import { langCodeToName, langSortCmp, sourceDefualtLangs, sourceForcedDefaultLangs } from 'util/language'; import useLocalStorage from 'util/useLocalStorage'; +import { ISource } from 'typings'; function sourceToLangList(sources: ISource[]) { const result: string[] = []; diff --git a/src/screens/SourceConfigure.tsx b/src/screens/SourceConfigure.tsx index 287a8621..0b41d61e 100644 --- a/src/screens/SourceConfigure.tsx +++ b/src/screens/SourceConfigure.tsx @@ -15,6 +15,7 @@ import EditTextPreference from 'components/sourceConfiguration/EditTextPreferenc import MultiSelectListPreference from 'components/sourceConfiguration/MultiSelectListPreference'; import List from '@mui/material/List'; import cloneObject from 'util/cloneObject'; +import { SourcePreferences } from 'typings'; function getPrefComponent(type: string) { switch (type) { diff --git a/src/screens/SourceMangas.tsx b/src/screens/SourceMangas.tsx index 91e9089e..0af7ad96 100644 --- a/src/screens/SourceMangas.tsx +++ b/src/screens/SourceMangas.tsx @@ -17,6 +17,7 @@ import AppbarSearch from 'components/util/AppbarSearch'; import { useQueryParam, StringParam } from 'use-query-params'; import SourceGridLayout from 'components/source/GridLayouts'; import { useLibraryOptionsContext } from 'components/context/LibraryOptionsContext'; +import { IManga, IMangaCard, ISource, ISourceFilters } from 'typings'; interface IPos { position: number; diff --git a/src/screens/Sources.tsx b/src/screens/Sources.tsx index c114ea71..d84c7535 100644 --- a/src/screens/Sources.tsx +++ b/src/screens/Sources.tsx @@ -16,6 +16,7 @@ import { IconButton } from '@mui/material'; import TravelExploreIcon from '@mui/icons-material/TravelExplore'; import { useHistory } from 'react-router-dom'; import { useQuery } from 'util/client'; +import { ISource } from 'typings'; function sourceToLangList(sources: ISource[]) { const result: string[] = []; diff --git a/src/screens/Updates.tsx b/src/screens/Updates.tsx index add299d4..f7548c53 100644 --- a/src/screens/Updates.tsx +++ b/src/screens/Updates.tsx @@ -21,6 +21,7 @@ import React, { useContext, useEffect, useRef, useState } from 'react'; import { Link, useHistory } from 'react-router-dom'; import client from 'util/client'; import useLocalStorage from 'util/useLocalStorage'; +import { IChapter, IMangaChapter, IQueue, PaginatedList } from 'typings'; function epochToDate(epoch: number) { const date = new Date(0); // The 0 there is the key, which sets the date to the epoch diff --git a/src/screens/settings/About.tsx b/src/screens/settings/About.tsx index 9e590984..a41afd7f 100644 --- a/src/screens/settings/About.tsx +++ b/src/screens/settings/About.tsx @@ -6,6 +6,7 @@ import ListItemLink from 'components/util/ListItemLink'; import NavbarContext from 'components/context/NavbarContext'; import LoadingPlaceholder from 'components/util/LoadingPlaceholder'; import { useQuery } from 'util/client'; +import { IAbout } from 'typings'; export default function About() { const { setTitle, setAction } = useContext(NavbarContext); diff --git a/src/screens/settings/Categories.tsx b/src/screens/settings/Categories.tsx index 04d35da6..1f7a961f 100644 --- a/src/screens/settings/Categories.tsx +++ b/src/screens/settings/Categories.tsx @@ -33,6 +33,7 @@ import Checkbox from '@mui/material/Checkbox'; import FormControlLabel from '@mui/material/FormControlLabel'; import NavbarContext from 'components/context/NavbarContext'; import client, { useQuery } from 'util/client'; +import { ICategory } from 'typings'; const getItemStyle = ( isDragging: boolean, diff --git a/src/screens/settings/DefaultReaderSettings.tsx b/src/screens/settings/DefaultReaderSettings.tsx index 1e3e9da1..706e4649 100644 --- a/src/screens/settings/DefaultReaderSettings.tsx +++ b/src/screens/settings/DefaultReaderSettings.tsx @@ -20,6 +20,7 @@ import { useDefaultReaderSettings, } from 'util/readerSettings'; import ReaderSettingsOptions from 'components/reader/ReaderSettingsOptions'; +import { IReaderSettings } from 'typings'; export default function DefaultReaderSettings() { const { setTitle, setAction } = useContext(NavbarContext); diff --git a/src/typings.d.ts b/src/typings.ts similarity index 72% rename from src/typings.d.ts rename to src/typings.ts index 8f305d28..b5357077 100644 --- a/src/typings.d.ts +++ b/src/typings.ts @@ -5,7 +5,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -interface IExtension { +import { OverridableComponent } from '@mui/material/OverridableComponent'; +import { SvgIconTypeMap } from '@mui/material/SvgIcon/SvgIcon'; + +export interface IExtension { name: string; pkgName: string; versionName: string; @@ -19,7 +22,7 @@ interface IExtension { obsolete: boolean; } -interface ISource { +export interface ISource { id: string; name: string; lang: string; @@ -30,12 +33,12 @@ interface ISource { displayName: string; } -interface ISourceFilters { +export interface ISourceFilters { type: string; filter: ISourceFilter; } -interface ISourceFilter { +export interface ISourceFilter { name: string; state: number | string | boolean | ISourceFilters[] | IState; values?: string[]; @@ -43,18 +46,18 @@ interface ISourceFilter { selected?: ISelected; } -interface ISelected { +export interface ISelected { displayname: string; value: string; _value: string; } -interface IState { +export interface IState { ascending: boolean; index: number; } -interface IMetadataMigration { +export interface IMetadataMigration { appKeyPrefix?: { oldPrefix: string; newPrefix: string }; values?: { /** @@ -68,23 +71,23 @@ interface IMetadataMigration { keys?: { oldKey: string; newKey: string }[]; } -interface IMetadata { +export interface IMetadata { [key: string]: VALUES; } -interface IMetadataHolder { +export interface IMetadataHolder { meta?: IMetadata; } -type AllowedMetadataValueTypes = string | boolean | number | undefined; +export type AllowedMetadataValueTypes = string | boolean | number | undefined; -type MangaMetadataKeys = keyof IReaderSettings; +export type MangaMetadataKeys = keyof IReaderSettings; -type AppMetadataKeys = MangaMetadataKeys; +export type AppMetadataKeys = MangaMetadataKeys; -type MetadataKeyValuePair = [AppMetadataKeys, AllowedMetadataValueTypes]; +export type MetadataKeyValuePair = [AppMetadataKeys, AllowedMetadataValueTypes]; -interface IMangaCard { +export interface IMangaCard { id: number; title: string; genre: string[]; @@ -95,7 +98,7 @@ interface IMangaCard { meta?: IMetadata; } -interface IManga { +export interface IManga { id: number; sourceId: string; @@ -123,7 +126,7 @@ interface IManga { chaptersAge: number; } -interface IChapter { +export interface IChapter { id: number; url: string; name: string; @@ -140,35 +143,35 @@ interface IChapter { chapterCount: number; pageCount: number; downloaded: boolean; - meta: IAppMetadata; + meta: IMetadata; } -interface IMangaChapter { +export interface IMangaChapter { manga: IManga; chapter: IChapter; } -interface IPartialChapter { +export interface IPartialChapter { pageCount: number; index: number; chapterCount: number; lastPageRead: number; } -interface ICategory { +export interface ICategory { id: number; order: number; name: string; default: boolean; - meta: IAppMetadata; + meta: IMetadata; } -interface INavbarOverride { +export interface INavbarOverride { status: boolean; value: any; } -type ReaderType = +export type ReaderType = | 'ContinuesVertical' | 'Webtoon' | 'SingleVertical' @@ -180,19 +183,19 @@ type ReaderType = | 'ContinuesHorizontalLTR' | 'ContinuesHorizontalRTL'; -interface IReaderSettings { +export interface IReaderSettings { staticNav: boolean; showPageNumber: boolean; loadNextOnEnding: boolean; readerType: ReaderType; } -interface IReaderPage { +export interface IReaderPage { index: number; src: string; } -interface IReaderProps { +export interface IReaderProps { pages: Array; pageCount: number; setCurPage: React.Dispatch>; @@ -205,7 +208,7 @@ interface IReaderProps { prevChapter: () => void; } -interface IAbout { +export interface IAbout { name: string; version: string; revision: string; @@ -215,7 +218,7 @@ interface IAbout { discord: string; } -interface IDownloadChapter { +export interface IDownloadChapter { chapterIndex: number; mangaId: number; state: 'Queued' | 'Downloading' | 'Finished' | 'Error'; @@ -224,12 +227,12 @@ interface IDownloadChapter { manga: IManga; } -interface IQueue { +export interface IQueue { status: 'Stopped' | 'Started'; queue: IDownloadChapter[]; } -interface IUpdateStatus { +export interface IUpdateStatus { running: boolean; statusMap: { COMPLETE?: IManga[]; @@ -238,7 +241,7 @@ interface IUpdateStatus { }; } -interface PreferenceProps { +export interface PreferenceProps { key: string; title: string; summary: string; @@ -250,37 +253,37 @@ interface PreferenceProps { updateValue: any; } -interface TwoStatePreferenceProps extends PreferenceProps { +export interface TwoStatePreferenceProps extends PreferenceProps { // intetnal props type: 'Switch' | 'Checkbox'; } -interface CheckBoxPreferenceProps extends PreferenceProps {} +export interface CheckBoxPreferenceProps extends PreferenceProps {} -interface SwitchPreferenceCompatProps extends PreferenceProps {} +export interface SwitchPreferenceCompatProps extends PreferenceProps {} -interface ListPreferenceProps extends PreferenceProps { +export interface ListPreferenceProps extends PreferenceProps { entries: string[]; entryValues: string[]; } -interface MultiSelectListPreferenceProps extends PreferenceProps { +export interface MultiSelectListPreferenceProps extends PreferenceProps { entries: string[]; entryValues: string[]; } -interface EditTextPreferenceProps extends PreferenceProps { +export interface EditTextPreferenceProps extends PreferenceProps { dialogTitle: string; dialogMessage: string; text: string; } -interface SourcePreferences { +export interface SourcePreferences { type: string; props: any; } -interface NavbarItem { +export interface NavbarItem { path: string; title: string; SelectedIconComponent: OverridableComponent>; @@ -288,16 +291,16 @@ interface NavbarItem { show: 'mobile' | 'desktop' | 'both'; } -interface PaginatedList { +export interface PaginatedList { page: T[]; hasNextPage: boolean; } -type NullAndUndefined = T | null | undefined; +export type NullAndUndefined = T | null | undefined; -type ChapterSortMode = 'fetchedAt' | 'source'; +export type ChapterSortMode = 'fetchedAt' | 'source'; -interface ChapterListOptions { +export interface ChapterListOptions { active: boolean; unread: NullAndUndefined; downloaded: NullAndUndefined; @@ -307,13 +310,13 @@ interface ChapterListOptions { showChapterNumber: boolean; } -type ChapterOptionsReducerAction = +export type ChapterOptionsReducerAction = | { type: 'filter'; filterType: string; filterValue: NullAndUndefined } | { type: 'sortBy'; sortBy: ChapterSortMode } | { type: 'sortReverse' } | { type: 'showChapterNumber' }; -type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortID'; +export type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortID'; enum GridLayout { Compact = 0, @@ -321,7 +324,7 @@ enum GridLayout { List = 2, } -interface LibraryOptions { +export interface LibraryOptions { // display options showDownloadBadge: boolean; showUnreadBadge: boolean; @@ -335,7 +338,7 @@ interface LibraryOptions { sortDesc: NullAndUndefined; } -interface BatchChaptersChange { +export interface BatchChaptersChange { delete?: boolean; isRead?: boolean; isBookmarked?: boolean; diff --git a/src/util/metadata.ts b/src/util/metadata.ts index f3e059a6..e1beff1b 100644 --- a/src/util/metadata.ts +++ b/src/util/metadata.ts @@ -8,6 +8,18 @@ import { mutate } from 'swr'; import client from 'util/client'; +import { + AllowedMetadataValueTypes, + AppMetadataKeys, + ICategory, + IManga, + IMangaCard, + IMangaChapter, + IMetadata, + IMetadataHolder, + IMetadataMigration, + MetadataKeyValuePair, +} from 'typings'; const APP_METADATA_KEY_PREFIX = 'webUI_'; diff --git a/src/util/readerSettings.ts b/src/util/readerSettings.ts index ac288d2c..60384362 100644 --- a/src/util/readerSettings.ts +++ b/src/util/readerSettings.ts @@ -8,6 +8,7 @@ import { getMetadataFrom, requestUpdateMangaMetadata, requestUpdateServerMetadata } from 'util/metadata'; import { useQuery } from 'util/client'; +import { IManga, IMetadata, IMetadataHolder, IReaderSettings, MetadataKeyValuePair } from 'typings'; export const getDefaultSettings = (forceUndefined: boolean = false) => ({