2021-03-26 04:17:02 +04:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2021-01-26 23:32:12 +03:30
|
|
|
* 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/. */
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
import { OverridableComponent } from '@mui/material/OverridableComponent';
|
|
|
|
|
import { SvgIconTypeMap } from '@mui/material/SvgIcon/SvgIcon';
|
2023-03-23 13:59:32 +01:00
|
|
|
import { TFuncKey } from 'i18next';
|
|
|
|
|
|
|
|
|
|
export type TranslationKey = TFuncKey;
|
2023-02-24 16:40:37 +01:00
|
|
|
|
|
|
|
|
export interface IExtension {
|
2023-02-06 10:06:33 +01:00
|
|
|
name: string;
|
|
|
|
|
pkgName: string;
|
|
|
|
|
versionName: string;
|
|
|
|
|
versionCode: number;
|
|
|
|
|
lang: string;
|
|
|
|
|
isNsfw: boolean;
|
|
|
|
|
apkName: string;
|
|
|
|
|
iconUrl: string;
|
|
|
|
|
installed: boolean;
|
|
|
|
|
hasUpdate: boolean;
|
|
|
|
|
obsolete: boolean;
|
2020-12-24 16:50:50 +01:00
|
|
|
}
|
2020-12-25 06:36:34 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface ISource {
|
2023-02-06 10:06:33 +01:00
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
lang: string;
|
|
|
|
|
iconUrl: string;
|
|
|
|
|
supportsLatest: boolean;
|
|
|
|
|
isConfigurable: boolean;
|
|
|
|
|
isNsfw: boolean;
|
|
|
|
|
displayName: string;
|
2020-12-25 06:36:34 +03:30
|
|
|
}
|
2020-12-25 17:42:22 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface ISourceFilters {
|
2023-02-06 10:06:33 +01:00
|
|
|
type: string;
|
|
|
|
|
filter: ISourceFilter;
|
2022-03-04 01:25:10 +00:00
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface ISourceFilter {
|
2023-02-06 10:06:33 +01:00
|
|
|
name: string;
|
|
|
|
|
state: number | string | boolean | ISourceFilters[] | IState;
|
|
|
|
|
values?: string[];
|
|
|
|
|
displayValues?: string[];
|
|
|
|
|
selected?: ISelected;
|
2022-03-04 01:25:10 +00:00
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface ISelected {
|
2023-02-06 10:06:33 +01:00
|
|
|
displayname: string;
|
|
|
|
|
value: string;
|
|
|
|
|
_value: string;
|
2022-03-04 01:25:10 +00:00
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IState {
|
2023-02-06 10:06:33 +01:00
|
|
|
ascending: boolean;
|
|
|
|
|
index: number;
|
2022-03-04 01:25:10 +00:00
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IMetadataMigration {
|
2023-02-06 10:06:33 +01:00
|
|
|
appKeyPrefix?: { oldPrefix: string; newPrefix: string };
|
2023-02-17 13:10:44 +01:00
|
|
|
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;
|
|
|
|
|
}[];
|
2023-02-06 10:06:33 +01:00
|
|
|
keys?: { oldKey: string; newKey: string }[];
|
2023-01-06 18:19:45 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IMetadata<VALUES extends AllowedMetadataValueTypes = string> {
|
2023-01-06 17:15:29 +01:00
|
|
|
[key: string]: VALUES;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IMetadataHolder<VALUES extends AllowedMetadataValueTypes = string> {
|
2023-02-06 10:06:33 +01:00
|
|
|
meta?: IMetadata<VALUES>;
|
2023-01-06 17:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type AllowedMetadataValueTypes = string | boolean | number | undefined;
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type MangaMetadataKeys = keyof IReaderSettings;
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-03-04 22:21:24 +05:30
|
|
|
export type SearchMetadataKeys = keyof ISearchSettings;
|
|
|
|
|
|
|
|
|
|
export type AppMetadataKeys = MangaMetadataKeys | SearchMetadataKeys;
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type MetadataKeyValuePair = [AppMetadataKeys, AllowedMetadataValueTypes];
|
2023-01-06 17:15:29 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IMangaCard {
|
2023-02-06 10:06:33 +01:00
|
|
|
id: number;
|
|
|
|
|
title: string;
|
2023-02-16 11:26:09 +05:30
|
|
|
genre: string[];
|
2023-02-06 10:06:33 +01:00
|
|
|
thumbnailUrl: string;
|
|
|
|
|
unreadCount?: number;
|
|
|
|
|
downloadCount?: number;
|
|
|
|
|
inLibrary?: boolean;
|
|
|
|
|
meta?: IMetadata;
|
2023-03-04 22:21:39 +05:30
|
|
|
inLibraryAt: number;
|
2023-03-05 12:26:50 +05:30
|
|
|
lastReadAt: number;
|
2021-03-17 19:17:03 +03:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IManga {
|
2023-02-06 10:06:33 +01:00
|
|
|
id: number;
|
|
|
|
|
sourceId: string;
|
2021-03-17 19:17:03 +03:30
|
|
|
|
2023-02-06 10:06:33 +01:00
|
|
|
url: string;
|
|
|
|
|
title: string;
|
|
|
|
|
thumbnailUrl: string;
|
2021-03-17 19:17:03 +03:30
|
|
|
|
2023-02-06 10:06:33 +01:00
|
|
|
artist: string;
|
|
|
|
|
author: string;
|
|
|
|
|
description: string;
|
|
|
|
|
genre: string[];
|
|
|
|
|
status: string;
|
2021-09-05 01:11:25 +04:30
|
|
|
|
2023-02-06 10:06:33 +01:00
|
|
|
inLibrary: boolean;
|
|
|
|
|
source: ISource;
|
2021-09-05 01:11:25 +04:30
|
|
|
|
2023-02-06 10:06:33 +01:00
|
|
|
meta: IMetadata;
|
2021-09-05 01:11:25 +04:30
|
|
|
|
2023-02-06 10:06:33 +01:00
|
|
|
realUrl: string;
|
|
|
|
|
freshData: boolean;
|
|
|
|
|
unreadCount?: number;
|
|
|
|
|
downloadCount?: number;
|
2022-11-02 10:42:02 +01:00
|
|
|
|
2023-02-06 10:06:33 +01:00
|
|
|
age: number;
|
|
|
|
|
chaptersAge: number;
|
2023-03-04 22:21:39 +05:30
|
|
|
chaptersLastFetchedAt: number;
|
|
|
|
|
inLibraryAt: number;
|
|
|
|
|
initialized: boolean;
|
|
|
|
|
lastChapterRead: NullAndUndefined<IChapter>;
|
|
|
|
|
lastFetchedAt: number;
|
|
|
|
|
lastReadAt: number;
|
|
|
|
|
thumbnailUrlLastFetched: number;
|
|
|
|
|
updateStrategy: string;
|
2021-09-05 01:11:25 +04:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IChapter {
|
2023-02-06 10:06:33 +01:00
|
|
|
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;
|
2023-02-24 16:40:37 +01:00
|
|
|
meta: IMetadata;
|
2021-01-19 21:02:57 +03:30
|
|
|
}
|
2021-02-20 01:23:52 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IMangaChapter {
|
2023-02-06 10:06:33 +01:00
|
|
|
manga: IManga;
|
|
|
|
|
chapter: IChapter;
|
2021-09-28 00:41:12 +03:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IPartialChapter {
|
2023-02-06 10:06:33 +01:00
|
|
|
pageCount: number;
|
|
|
|
|
index: number;
|
|
|
|
|
chapterCount: number;
|
|
|
|
|
lastPageRead: number;
|
2021-03-23 03:50:55 +04:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface ICategory {
|
2023-02-06 10:06:33 +01:00
|
|
|
id: number;
|
|
|
|
|
order: number;
|
|
|
|
|
name: string;
|
|
|
|
|
default: boolean;
|
2023-02-24 16:40:37 +01:00
|
|
|
meta: IMetadata;
|
2021-02-20 01:23:52 +03:30
|
|
|
}
|
2021-03-18 21:46:24 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface INavbarOverride {
|
2023-02-06 10:06:33 +01:00
|
|
|
status: boolean;
|
|
|
|
|
value: any;
|
2021-03-29 02:47:51 +04:30
|
|
|
}
|
2021-05-15 17:18:57 +04:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type ReaderType =
|
2023-02-06 10:06:33 +01:00
|
|
|
| 'ContinuesVertical'
|
|
|
|
|
| 'Webtoon'
|
|
|
|
|
| 'SingleVertical'
|
|
|
|
|
| 'SingleRTL'
|
|
|
|
|
| 'SingleLTR'
|
|
|
|
|
| 'DoubleVertical'
|
|
|
|
|
| 'DoubleRTL'
|
|
|
|
|
| 'DoubleLTR'
|
|
|
|
|
| 'ContinuesHorizontalLTR'
|
|
|
|
|
| 'ContinuesHorizontalRTL';
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IReaderSettings {
|
2023-02-06 10:06:33 +01:00
|
|
|
staticNav: boolean;
|
|
|
|
|
showPageNumber: boolean;
|
|
|
|
|
loadNextOnEnding: boolean;
|
2023-04-05 13:37:12 +02:00
|
|
|
skipDupChapters: boolean;
|
2023-02-06 10:06:33 +01:00
|
|
|
readerType: ReaderType;
|
2021-05-15 17:18:57 +04:30
|
|
|
}
|
|
|
|
|
|
2023-04-05 13:37:12 +02:00
|
|
|
export enum ChapterOffset {
|
|
|
|
|
PREV = -1,
|
|
|
|
|
NEXT = 1,
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 22:21:24 +05:30
|
|
|
export interface ISearchSettings {
|
|
|
|
|
ignoreFilters: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IReaderPage {
|
2023-02-06 10:06:33 +01:00
|
|
|
index: number;
|
|
|
|
|
src: string;
|
2021-05-15 17:18:57 +04:30
|
|
|
}
|
2021-05-15 23:22:37 +04:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IReaderProps {
|
2023-02-06 10:06:33 +01:00
|
|
|
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;
|
2021-05-15 23:22:37 +04:30
|
|
|
}
|
2021-05-25 21:06:27 +04:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IAbout {
|
2023-02-06 10:06:33 +01:00
|
|
|
name: string;
|
|
|
|
|
version: string;
|
|
|
|
|
revision: string;
|
|
|
|
|
buildType: 'Stable' | 'Preview';
|
|
|
|
|
buildTime: number;
|
|
|
|
|
github: string;
|
|
|
|
|
discord: string;
|
2021-05-25 21:06:27 +04:30
|
|
|
}
|
2021-05-30 04:01:49 +04:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IDownloadChapter {
|
2023-02-06 10:06:33 +01:00
|
|
|
chapterIndex: number;
|
|
|
|
|
mangaId: number;
|
|
|
|
|
state: 'Queued' | 'Downloading' | 'Finished' | 'Error';
|
|
|
|
|
progress: number;
|
|
|
|
|
chapter: IChapter;
|
|
|
|
|
manga: IManga;
|
2021-05-30 04:01:49 +04:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IQueue {
|
2023-02-06 10:06:33 +01:00
|
|
|
status: 'Stopped' | 'Started';
|
|
|
|
|
queue: IDownloadChapter[];
|
2021-05-30 04:01:49 +04:30
|
|
|
}
|
2021-08-06 04:53:53 +04:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface IUpdateStatus {
|
2023-02-06 10:06:33 +01:00
|
|
|
running: boolean;
|
2022-04-18 10:26:36 +02:00
|
|
|
statusMap: {
|
2023-02-06 10:06:33 +01:00
|
|
|
COMPLETE?: IManga[];
|
|
|
|
|
RUNNING?: IManga[];
|
|
|
|
|
PENDING?: IManga[];
|
|
|
|
|
};
|
2022-04-18 10:26:36 +02:00
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface PreferenceProps {
|
2023-02-06 10:06:33 +01:00
|
|
|
key: string;
|
|
|
|
|
title: string;
|
|
|
|
|
summary: string;
|
|
|
|
|
defaultValue: any;
|
|
|
|
|
currentValue: any;
|
|
|
|
|
defaultValueType: string;
|
2021-09-13 19:18:21 +04:30
|
|
|
|
|
|
|
|
// intetnal props
|
2023-02-06 10:06:33 +01:00
|
|
|
updateValue: any;
|
2021-08-06 04:53:53 +04:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface TwoStatePreferenceProps extends PreferenceProps {
|
2021-09-13 19:18:21 +04:30
|
|
|
// intetnal props
|
2023-02-06 10:06:33 +01:00
|
|
|
type: 'Switch' | 'Checkbox';
|
2021-09-13 19:18:21 +04:30
|
|
|
}
|
2023-02-06 10:06:33 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface CheckBoxPreferenceProps extends PreferenceProps {}
|
2021-11-29 19:08:02 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface SwitchPreferenceCompatProps extends PreferenceProps {}
|
2021-11-29 19:08:02 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface ListPreferenceProps extends PreferenceProps {
|
2023-02-06 10:06:33 +01:00
|
|
|
entries: string[];
|
|
|
|
|
entryValues: string[];
|
2021-09-13 19:18:21 +04:30
|
|
|
}
|
2021-11-29 19:08:02 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface MultiSelectListPreferenceProps extends PreferenceProps {
|
2023-02-06 10:06:33 +01:00
|
|
|
entries: string[];
|
|
|
|
|
entryValues: string[];
|
2021-11-29 19:08:02 +03:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface EditTextPreferenceProps extends PreferenceProps {
|
2023-02-06 10:06:33 +01:00
|
|
|
dialogTitle: string;
|
|
|
|
|
dialogMessage: string;
|
|
|
|
|
text: string;
|
2021-09-13 19:18:21 +04:30
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface SourcePreferences {
|
2023-02-06 10:06:33 +01:00
|
|
|
type: string;
|
|
|
|
|
props: any;
|
2021-08-06 04:53:53 +04:30
|
|
|
}
|
2021-10-24 21:34:38 +05:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface NavbarItem {
|
2023-02-06 10:06:33 +01:00
|
|
|
path: string;
|
2023-03-23 13:59:32 +01:00
|
|
|
title: TranslationKey;
|
2023-02-06 10:06:33 +01:00
|
|
|
SelectedIconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
|
|
|
|
|
IconComponent: OverridableComponent<SvgIconTypeMap<{}, 'svg'>>;
|
|
|
|
|
show: 'mobile' | 'desktop' | 'both';
|
2021-10-24 21:34:38 +05:30
|
|
|
}
|
2021-11-10 23:04:04 +03:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface PaginatedList<T> {
|
2023-02-06 10:06:33 +01:00
|
|
|
page: T[];
|
|
|
|
|
hasNextPage: boolean;
|
2021-11-10 23:04:04 +03:30
|
|
|
}
|
2021-12-13 19:52:56 +05:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type NullAndUndefined<T> = T | null | undefined;
|
2021-12-13 19:52:56 +05:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type ChapterSortMode = 'fetchedAt' | 'source';
|
2021-12-13 19:52:56 +05:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface ChapterListOptions {
|
2023-02-06 10:06:33 +01:00
|
|
|
active: boolean;
|
|
|
|
|
unread: NullAndUndefined<boolean>;
|
|
|
|
|
downloaded: NullAndUndefined<boolean>;
|
|
|
|
|
bookmarked: NullAndUndefined<boolean>;
|
|
|
|
|
reverse: boolean;
|
|
|
|
|
sortBy: ChapterSortMode;
|
|
|
|
|
showChapterNumber: boolean;
|
2021-12-13 19:52:56 +05:30
|
|
|
}
|
2022-01-24 15:09:28 +05:30
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export type ChapterOptionsReducerAction =
|
2023-02-06 10:06:33 +01:00
|
|
|
| { type: 'filter'; filterType: string; filterValue: NullAndUndefined<boolean> }
|
|
|
|
|
| { type: 'sortBy'; sortBy: ChapterSortMode }
|
|
|
|
|
| { type: 'sortReverse' }
|
|
|
|
|
| { type: 'showChapterNumber' };
|
2022-03-03 18:19:01 +05:30
|
|
|
|
2023-03-05 12:26:50 +05:30
|
|
|
export type LibrarySortMode = 'sortToRead' | 'sortAlph' | 'sortDateAdded' | 'sortLastRead';
|
2022-11-24 09:41:03 +01:00
|
|
|
|
2022-12-20 07:05:31 +02:00
|
|
|
enum GridLayout {
|
|
|
|
|
Compact = 0,
|
|
|
|
|
Comfortable = 1,
|
|
|
|
|
List = 2,
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface LibraryOptions {
|
2022-04-07 12:53:14 +02:00
|
|
|
// display options
|
2023-02-06 10:06:33 +01:00
|
|
|
showDownloadBadge: boolean;
|
|
|
|
|
showUnreadBadge: boolean;
|
|
|
|
|
gridLayout: GridLayout;
|
|
|
|
|
SourcegridLayout: GridLayout;
|
2022-04-07 12:53:14 +02:00
|
|
|
|
|
|
|
|
// filter options
|
2023-02-06 10:06:33 +01:00
|
|
|
downloaded: NullAndUndefined<boolean>;
|
|
|
|
|
unread: NullAndUndefined<boolean>;
|
|
|
|
|
sorts: NullAndUndefined<LibrarySortMode>;
|
|
|
|
|
sortDesc: NullAndUndefined<boolean>;
|
2022-03-03 18:19:01 +05:30
|
|
|
}
|
2022-11-21 01:33:21 +01:00
|
|
|
|
2023-02-24 16:40:37 +01:00
|
|
|
export interface BatchChaptersChange {
|
2023-02-06 10:06:33 +01:00
|
|
|
delete?: boolean;
|
|
|
|
|
isRead?: boolean;
|
|
|
|
|
isBookmarked?: boolean;
|
|
|
|
|
lastPageRead?: number;
|
2022-11-21 01:33:21 +01:00
|
|
|
}
|