blob: 4cbc65aad7c83ad5a7b9fb72c3983db864c28d1b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<script lang="ts">
import Notice from '$lib/Error/Notice.svelte';
import Message from '$lib/Loading/Message.svelte';
import MangaDexChapters from '$lib/Reader/Chapters/MangaDex.svelte';
import RawkumaChapters from '$lib/Reader/Chapters/Rawkuma.svelte';
import { decodeResource, fetchResource, identify, Resource } from '$lib/Reader/resource';
import InputTemplate from '$lib/Tools/InputTemplate.svelte';
let submission = $state('');
let resourceIdentity = $derived(identify(submission));
</script>
<InputTemplate field="Manga URL" bind:submission submitText="Read" preserveCase>
{#if resourceIdentity}
{#await fetchResource(submission)}
<Message message="Loading chapters ..." />
{:then response}
{#if response.ok}
{#await decodeResource(response, submission) then data}
{#if resourceIdentity === Resource.MangaDex}
<MangaDexChapters {data} />
{:else if resourceIdentity === Resource.Rawkuma}
<RawkumaChapters {data} />
{/if}
{:catch error}
<Notice>{error}</Notice>
{/await}
{:else}
<Notice>Failed to fetch data</Notice>
{/if}
{:catch}
<Notice>An unknown error has occurred.</Notice>
{/await}
{:else}
<Notice>Invalid URL</Notice>
{/if}
</InputTemplate>
|