diff --git a/packages/typescript/Quran/src/index.ts b/packages/typescript/Quran/src/index.ts index 652e89c..a0e9ab1 100644 --- a/packages/typescript/Quran/src/index.ts +++ b/packages/typescript/Quran/src/index.ts @@ -1,8 +1,8 @@ type TLocale = "ar" | "en"; -type TAyat = Ayah[]; +type TAyat = Ayah[]; type TQuran = { locale: TLocale; - surahs: Surah[]; + surahs: Surah[]; } type TSurah = { readonly id: number; @@ -16,17 +16,17 @@ type TAyah = { body: string; } -class Quran { +class Quran { locale: TLocale; - surahs: Surah[]; + surahs: Surah[]; - constructor(self: T) { + constructor(self: TQuran) { this.locale = self.locale; this.surahs = self.surahs; } } -class Surah { +class Surah { readonly id: number; readonly name: string; readonly numberOfAyah: number; @@ -34,7 +34,7 @@ class Surah { readonly utf8: { codepoints: number[] }; readonly ayat: TAyat - constructor(self: T) { + constructor(self: TSurah) { this.id = self.id; this.name = self.name; this.numberOfAyah = self.numberOfAyah; @@ -53,12 +53,12 @@ class Surah { } } -class Ayah { +class Ayah { readonly id: number; readonly body: string; ms: number; - constructor(self: T) { + constructor(self: TAyah) { this.id = self.id; this.body = self.body; this.ms = 0; diff --git a/src/js/components/AudioControl.tsx b/src/js/components/AudioControl.tsx index 1ab8e76..09e98e8 100644 --- a/src/js/components/AudioControl.tsx +++ b/src/js/components/AudioControl.tsx @@ -1,5 +1,5 @@ -import type { Surah, TSurah, Ayah, TAyah } from "Quran"; -import React, { useEffect, useMemo, useState } from "react"; +import React, { useEffect, useState } from "react"; +import type { Surah, Ayah } from "Quran"; import { SoundOnIcon, SoundOffIcon } from "~/components/Icon"; export type TAudioStatus = "play" | "pause" | "wait" | "end"; @@ -8,8 +8,8 @@ type Maybe = T | null | undefined; type TChangeFuncs = [() => void, () => void]; type Props = { audio: HTMLAudioElement; - surah: Surah; - ayah: Maybe>; + surah: Surah; + ayah: Maybe; hidden?: boolean; onStatusChange?: (s: TAudioStatus, fns: TChangeFuncs) => void; }; diff --git a/src/js/components/Stream.tsx b/src/js/components/Stream.tsx index 37d7cce..97b0165 100644 --- a/src/js/components/Stream.tsx +++ b/src/js/components/Stream.tsx @@ -1,11 +1,11 @@ import React, { useEffect, useMemo, useRef } from "react"; -import { Surah, Ayah, TAyah, TAyat, TSurah, TLocale } from "Quran"; +import type { Surah, Ayah, TAyat, TLocale } from "Quran"; import { AudioControl } from "~/components/AudioControl"; import { formatNumber, TFunction } from "~/lib/t"; import classNames from "classnames"; type Props = { - surah: Surah; + surah: Surah; stream: TAyat; locale: TLocale; endOfStream: boolean; @@ -35,7 +35,7 @@ export function Stream({ )} ref={ref} > - {stream.map((ayah: Ayah) => { + {stream.map((ayah: Ayah) => { return (
  • []) => void; - surahs: Surah[]; + setIndex: (k: Surah[]) => void; + surahs: Surah[]; }; export function Filter({ t, locale, setIndex, surahs }: Props) { diff --git a/src/js/components/SurahIndex/index.tsx b/src/js/components/SurahIndex/index.tsx index 927f8f3..01c795f 100644 --- a/src/js/components/SurahIndex/index.tsx +++ b/src/js/components/SurahIndex/index.tsx @@ -1,5 +1,5 @@ import React, { useRef, useState, useEffect } from "react"; -import { TLocale, TSurah, Surah } from "Quran"; +import type { Surah, TLocale } from "Quran"; import { useTheme } from "~/hooks/useTheme"; import { formatNumber, TFunction } from "~/lib/t"; import { RightArrow } from "~/components/Icon"; @@ -9,13 +9,13 @@ import classNames from "classnames"; type Props = { locale: TLocale; - surahs: Surah[]; + surahs: Surah[]; t: TFunction; }; export function SurahIndex({ locale, surahs, t }: Props) { const [theme, setTheme] = useTheme(); - const [index, setIndex] = useState[]>(surahs); + const [index, setIndex] = useState(surahs); const ref = useRef(); const ltr = locale === "en"; diff --git a/src/js/components/SurahStream.tsx b/src/js/components/SurahStream.tsx index a0ea138..f7a3c33 100644 --- a/src/js/components/SurahStream.tsx +++ b/src/js/components/SurahStream.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useMemo, useRef } from "react"; import classNames from "classnames"; -import { Surah, Ayah, TAyah, TSurah, TAyat, TLocale } from "Quran"; +import type { Surah, Ayah, TAyat, TLocale } from "Quran"; import { useTheme } from "~/hooks/useTheme"; import { Timer } from "~/components/Timer"; import { Stream } from "~/components/Stream"; @@ -17,7 +17,7 @@ import { TFunction } from "~/lib/t"; type Maybe = T | null | undefined; type Props = { - surah: Surah; + surah: Surah; locale: TLocale; t: TFunction; }; @@ -32,7 +32,7 @@ export function SurahStream({ surah, locale, t }: Props) { const ref = useRef(); const audio = useMemo(() => new Audio(), []); const readyToRender = stream.length > 0; - const ayah: Maybe> = stream[stream.length - 1]; + const ayah: Maybe = stream[stream.length - 1]; useEffect(() => { if (ref.current) { diff --git a/src/js/components/Timer.tsx b/src/js/components/Timer.tsx index c75967e..7819afa 100644 --- a/src/js/components/Timer.tsx +++ b/src/js/components/Timer.tsx @@ -1,11 +1,11 @@ import React, { useEffect } from "react"; -import { Surah, Ayah, TAyah, TSurah, TLocale, TAyat } from "Quran"; +import type { Surah, Ayah, TLocale, TAyat } from "Quran"; import { formatNumber } from "~/lib/t"; type Maybe = T | null | undefined; type Props = { - surah: Surah; + surah: Surah; locale: TLocale; stream: TAyat; setStream: (stream: TAyat) => void; @@ -27,8 +27,8 @@ export function Timer({ ms, setMs, }: Props) { - const ayah: Maybe> = stream[stream.length - 1]; - const lastAyah: Maybe> = surah.ayat[surah.ayat.length - 1]; + const ayah: Maybe = stream[stream.length - 1]; + const lastAyah: Maybe = surah.ayat[surah.ayat.length - 1]; useEffect(() => { if (!ayah) { diff --git a/src/js/main/surah-index.tsx b/src/js/main/surah-index.tsx index 963d409..4525890 100644 --- a/src/js/main/surah-index.tsx +++ b/src/js/main/surah-index.tsx @@ -8,7 +8,7 @@ import { SurahIndex } from "~/components/SurahIndex"; const root: HTMLElement = document.querySelector(".root")!; const locale = root.getAttribute("data-locale") as TLocale; const t = T(require("@json/t.json")); - const surahs: Surah[] = require("@json/surahs").map( + const surahs: Surah[] = require("@json/surahs").map( (e: TSurah) => new Surah(e), ); ReactDOM.createRoot(root).render( diff --git a/src/js/main/surah-stream.tsx b/src/js/main/surah-stream.tsx index bfdc75d..c8574e7 100644 --- a/src/js/main/surah-stream.tsx +++ b/src/js/main/surah-stream.tsx @@ -23,7 +23,7 @@ import { SurahStream } from "~/components/SurahStream"; } for (let i = 0; i < surah.ayat.length; i++) { const ayah = surah.ayat[i]; - const [_, ms] = blob2[i]; + const [, ms] = blob2[i]; ayah.ms = ms * 1000; }