Skip to content

Commit

Permalink
WIP: support get mode reader
Browse files Browse the repository at this point in the history
  • Loading branch information
tachibana-shin committed Dec 4, 2023
1 parent b02a04f commit e697d8a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
21 changes: 20 additions & 1 deletion npm/raiku-pgs/lib/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export interface Package {

readonly resolveImage: readonly Replacer[]

readonly supportGetMode?: boolean

readonly homepage?: string
readonly repository?: string

Expand Down Expand Up @@ -248,6 +250,12 @@ export interface ComicChapter {
readonly comments: readonly Comment[]
readonly comments_count: number
readonly comments_pages: number

readonly mode?: {
readonly singlePage?: boolean
readonly rightToLeft?: boolean
readonly scrollingMode?: boolean
}
}
export interface General {
readonly name: string
Expand All @@ -263,12 +271,14 @@ export interface Comments {
readonly comments_pages: number
}

export declare class API {
export declare class API<AutoFetchComicIsManga extends boolean = false> {
// public readonly package: Package

public readonly Servers: readonly Server[]
public readonly Rankings: readonly Ranking[]

public readonly autoFetchComicIsManga: AutoFetchComicIsManga

setup(): Promise<void>

index(): Promise<
Expand All @@ -280,6 +290,15 @@ export declare class API {
>

getComic(zlugComic: ID): Promise<Comic>
getModeReader?(
comic: string,
sourceId: string,
comicData: AutoFetchComicIsManga extends true ? Comic : undefined
): Promise<{
readonly singlePage?: boolean
readonly rightToLeft?: boolean
readonly scrollingMode?: boolean
}>
getComicChapter<Fast extends boolean>(
zlugComic: ID,
chap: ID,
Expand Down
2 changes: 2 additions & 0 deletions npm/raiku-pgs/lib/thread.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from "./thread/parseDom"
export * from "./thread/create-worker-plugin"
export * from "./thread/exec-package-mjs"

export * from "./API"
24 changes: 16 additions & 8 deletions src/pages/~[sourceId]/comic/[comic]/chap-[chap].vue
Original file line number Diff line number Diff line change
Expand Up @@ -717,16 +717,24 @@ const fetchComic = async () => {
watchEffect(async () => {
try {
if (localStateRestored.value) return

const reader = await api.getModeReader(
void props.comic
void api.value
if (!(await pluginStore.get(props.sourceId)).meta.supportGetMode) return

const $api = await api.value

const reader = await (await $api.getModeReader)!(

Check warning on line 726 in src/pages/~[sourceId]/comic/[comic]/chap-[chap].vue

View workflow job for this annotation

GitHub Actions / Run eslint scanning

Forbidden non-null assertion
props.comic,
props.sourceID,
(await api.autoFetchComicIsManga) ? await fetchComic() : undefined
props.sourceId,
((await $api.autoFetchComicIsManga)
? await fetchComic()
: undefined) as unknown as any

Check warning on line 731 in src/pages/~[sourceId]/comic/[comic]/chap-[chap].vue

View workflow job for this annotation

GitHub Actions / Run eslint scanning

Unexpected any. Specify a different type
)

if (reader.singlePage !== undefined) singlePage.value = reader.singlePage
if (reader.rightToLeft !== undefined) rightToLeft.value = reader.rightToLeft
if (reader.scrollingMode !== undefined)
if (reader?.singlePage !== undefined) singlePage.value = reader.singlePage
if (reader?.rightToLeft !== undefined)
rightToLeft.value = reader.rightToLeft
if (reader?.scrollingMode !== undefined)
scrollingMode.value = reader.scrollingMode
} catch (err) {
WARN(err)
Expand Down Expand Up @@ -917,7 +925,7 @@ const localStateRestored = useLocalStoreProgressEp({
scrollingMode,
currentPage,
maxPage: sizePage,
omm
zoom
})

const showToolbar = ref(true)
Expand Down

0 comments on commit e697d8a

Please sign in to comment.