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
This commit is contained in:
346
src/typings.ts
Normal file
346
src/typings.ts
Normal file
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
import { OverridableComponent } from '@mui/material/OverridableComponent';
|
||||
import { SvgIconTypeMap } from '@mui/material/SvgIcon/SvgIcon';
|
||||
|
||||
export interface IExtension {
|
||||
name: string;
|
||||
pkgName: string;
|
||||
versionName: string;
|
||||
versionCode: number;
|
||||
lang: string;
|
||||
isNsfw: boolean;
|
||||
apkName: string;
|
||||
iconUrl: string;
|
||||
installed: boolean;
|
||||
hasUpdate: boolean;
|
||||
obsolete: boolean;
|
||||
}
|
||||
|
||||
export interface ISource {
|
||||
id: string;
|
||||
name: string;
|
||||
lang: string;
|
||||
iconUrl: string;
|
||||
supportsLatest: boolean;
|
||||
isConfigurable: boolean;
|
||||
isNsfw: boolean;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export interface ISourceFilters {
|
||||
type: string;
|
||||
filter: ISourceFilter;
|
||||
}
|
||||
|
||||
export interface ISourceFilter {
|
||||
name: string;
|
||||
state: number | string | boolean | ISourceFilters[] | IState;
|
||||
values?: string[];
|
||||
displayValues?: string[];
|
||||
selected?: ISelected;
|
||||
}
|
||||
|
||||
export interface ISelected {
|
||||
displayname: string;
|
||||
value: string;
|
||||
_value: string;
|
||||
}
|
||||
|
||||
export interface IState {
|
||||
ascending: boolean;
|
||||
index: number;
|
||||
}
|
||||
|
||||
export interface IMetadataMigration {
|
||||
appKeyPrefix?: { oldPrefix: string; newPrefix: string };
|
||||
values?: {
|
||||
/**
|
||||
* In case the migration should only be applied to a specific metadata key.
|
||||
* Otherwise, all metadata keys will get migrated.
|
||||
*/
|
||||
key?: string;
|
||||
oldValue: string;
|
||||
newValue: string;
|
||||
}[];
|
||||
keys?: { oldKey: string; newKey: string }[];
|
||||
}
|
||||
|
||||
export interface IMetadata<VALUES extends AllowedMetadataValueTypes = string> {
|
||||
[key: string]: VALUES;
|
||||
}
|
||||
|
||||
export interface IMetadataHolder<VALUES extends AllowedMetadataValueTypes = string> {
|
||||
meta?: IMetadata<VALUES>;
|
||||
}
|
||||
|
||||
export type AllowedMetadataValueTypes = string | boolean | number | undefined;
|
||||
|
||||
export type MangaMetadataKeys = keyof IReaderSettings;
|
||||
|
||||
export type AppMetadataKeys = MangaMetadataKeys;
|
||||
|
||||
export type MetadataKeyValuePair = [AppMetadataKeys, AllowedMetadataValueTypes];
|
||||
|
||||
export interface IMangaCard {
|
||||
id: number;
|
||||
title: string;
|
||||
genre: string[];
|
||||
thumbnailUrl: string;
|
||||
unreadCount?: number;
|
||||
downloadCount?: number;
|
||||
inLibrary?: boolean;
|
||||
meta?: IMetadata;
|
||||
}
|
||||
|
||||
export interface IManga {
|
||||
id: number;
|
||||
sourceId: string;
|
||||
|
||||
url: string;
|
||||
title: string;
|
||||
thumbnailUrl: string;
|
||||
|
||||
artist: string;
|
||||
author: string;
|
||||
description: string;
|
||||
genre: string[];
|
||||
status: string;
|
||||
|
||||
inLibrary: boolean;
|
||||
source: ISource;
|
||||
|
||||
meta: IMetadata;
|
||||
|
||||
realUrl: string;
|
||||
freshData: boolean;
|
||||
unreadCount?: number;
|
||||
downloadCount?: number;
|
||||
|
||||
age: number;
|
||||
chaptersAge: number;
|
||||
}
|
||||
|
||||
export interface IChapter {
|
||||
id: number;
|
||||
url: string;
|
||||
name: string;
|
||||
uploadDate: number;
|
||||
chapterNumber: number;
|
||||
scanlator: string;
|
||||
mangaId: number;
|
||||
read: boolean;
|
||||
bookmarked: boolean;
|
||||
lastPageRead: number;
|
||||
lastReadAt: number;
|
||||
index: number;
|
||||
fetchedAt: number;
|
||||
chapterCount: number;
|
||||
pageCount: number;
|
||||
downloaded: boolean;
|
||||
meta: IMetadata;
|
||||
}
|
||||
|
||||
export interface IMangaChapter {
|
||||
manga: IManga;
|
||||
chapter: IChapter;
|
||||
}
|
||||
|
||||
export interface IPartialChapter {
|
||||
pageCount: number;
|
||||
index: number;
|
||||
chapterCount: number;
|
||||
lastPageRead: number;
|
||||
}
|
||||
|
||||
export interface ICategory {
|
||||
id: number;
|
||||
order: number;
|
||||
name: string;
|
||||
default: boolean;
|
||||
meta: IMetadata;
|
||||
}
|
||||
|
||||
export interface INavbarOverride {
|
||||
status: boolean;
|
||||
value: any;
|
||||
}
|
||||
|
||||
export type ReaderType =
|
||||
| 'ContinuesVertical'
|
||||
| 'Webtoon'
|
||||
| 'SingleVertical'
|
||||
| 'SingleRTL'
|
||||
| 'SingleLTR'
|
||||
| 'DoubleVertical'
|
||||
| 'DoubleRTL'
|
||||
| 'DoubleLTR'
|
||||
| 'ContinuesHorizontalLTR'
|
||||
| 'ContinuesHorizontalRTL';
|
||||
|
||||
export interface IReaderSettings {
|
||||
staticNav: boolean;
|
||||
showPageNumber: boolean;
|
||||
loadNextOnEnding: boolean;
|
||||
readerType: ReaderType;
|
||||
}
|
||||
|
||||
export interface IReaderPage {
|
||||
index: number;
|
||||
src: string;
|
||||
}
|
||||
|
||||
export interface IReaderProps {
|
||||
pages: Array<IReaderPage>;
|
||||
pageCount: number;
|
||||
setCurPage: React.Dispatch<React.SetStateAction<number>>;
|
||||
curPage: number;
|
||||
initialPage: number;
|
||||
settings: IReaderSettings;
|
||||
manga: IMangaCard | IManga;
|
||||
chapter: IChapter | IPartialChapter;
|
||||
nextChapter: () => void;
|
||||
prevChapter: () => void;
|
||||
}
|
||||
|
||||
export interface IAbout {
|
||||
name: string;
|
||||
version: string;
|
||||
revision: string;
|
||||
buildType: 'Stable' | 'Preview';
|
||||
buildTime: number;
|
||||
github: string;
|
||||
discord: string;
|
||||
}
|
||||
|
||||
export interface IDownloadChapter {
|
||||
chapterIndex: number;
|
||||
mangaId: number;
|
||||
state: 'Queued' | 'Downloading' | 'Finished' | 'Error';
|
||||
progress: number;
|
||||
chapter: IChapter;
|
||||
manga: IManga;
|
||||
}
|
||||
|
||||
export interface IQueue {
|
||||
status: 'Stopped' | 'Started';
|
||||
queue: IDownloadChapter[];
|
||||
}
|
||||
|
||||
export interface IUpdateStatus {
|
||||
running: boolean;
|
||||
statusMap: {
|
||||
COMPLETE?: IManga[];
|
||||
RUNNING?: IManga[];
|
||||
PENDING?: IManga[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface PreferenceProps {
|
||||
key: string;
|
||||
title: string;
|
||||
summary: string;
|
||||
defaultValue: any;
|
||||
currentValue: any;
|
||||
defaultValueType: string;
|
||||
|
||||
// intetnal props
|
||||
updateValue: any;
|
||||
}
|
||||
|
||||
export interface TwoStatePreferenceProps extends PreferenceProps {
|
||||
// intetnal props
|
||||
type: 'Switch' | 'Checkbox';
|
||||
}
|
||||
|
||||
export interface CheckBoxPreferenceProps extends PreferenceProps {}
|
||||
|
||||
export interface SwitchPreferenceCompatProps extends PreferenceProps {}
|
||||
|
||||
export interface ListPreferenceProps extends PreferenceProps {
|
||||
entries: string[];
|
||||
entryValues: string[];
|
||||
}
|
||||
|
||||
export interface MultiSelectListPreferenceProps extends PreferenceProps {
|
||||
entries: string[];
|
||||
entryValues: string[];
|
||||
}
|
||||
|
||||
export interface EditTextPreferenceProps extends PreferenceProps {
|
||||
dialogTitle: string;
|
||||
dialogMessage: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface SourcePreferences {
|
||||
type: string;
|
||||
props: any;
|
||||
}
|
||||
|
||||
export interface NavbarItem {
|
||||
path: string;
|
||||
title: string;
|
||||
SelectedIconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
|
||||
IconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
|
||||
show: 'mobile' | 'desktop' | 'both';
|
||||
}
|
||||
|
||||
export interface PaginatedList<T> {
|
||||
page: T[];
|
||||
hasNextPage: boolean;
|
||||
}
|
||||
|
||||
export type NullAndUndefined<T> = T | null | undefined;
|
||||
|
||||
export type ChapterSortMode = 'fetchedAt' | 'source';
|
||||
|
||||
export interface ChapterListOptions {
|
||||
active: boolean;
|
||||
unread: NullAndUndefined<boolean>;
|
||||
downloaded: NullAndUndefined<boolean>;
|
||||
bookmarked: NullAndUndefined<boolean>;
|
||||
reverse: boolean;
|
||||
sortBy: ChapterSortMode;
|
||||
showChapterNumber: boolean;
|
||||
}
|
||||
|
||||
export type ChapterOptionsReducerAction =
|
||||
| { type: 'filter'; filterType: string; filterValue: NullAndUndefined<boolean> }
|
||||
| { type: 'sortBy'; sortBy: ChapterSortMode }
|
||||
| { type: 'sortReverse' }
|
||||
| { type: 'showChapterNumber' };
|
||||
|
||||
export type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortID';
|
||||
|
||||
enum GridLayout {
|
||||
Compact = 0,
|
||||
Comfortable = 1,
|
||||
List = 2,
|
||||
}
|
||||
|
||||
export interface LibraryOptions {
|
||||
// display options
|
||||
showDownloadBadge: boolean;
|
||||
showUnreadBadge: boolean;
|
||||
gridLayout: GridLayout;
|
||||
SourcegridLayout: GridLayout;
|
||||
|
||||
// filter options
|
||||
downloaded: NullAndUndefined<boolean>;
|
||||
unread: NullAndUndefined<boolean>;
|
||||
sorts: NullAndUndefined<LibrarySortMode>;
|
||||
sortDesc: NullAndUndefined<boolean>;
|
||||
}
|
||||
|
||||
export interface BatchChaptersChange {
|
||||
delete?: boolean;
|
||||
isRead?: boolean;
|
||||
isBookmarked?: boolean;
|
||||
lastPageRead?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user