diff --git a/src/js/loaders/SurahIndexLoader.ts b/src/js/loaders/SurahIndexLoader.ts index b7ff37d..258a4cb 100644 --- a/src/js/loaders/SurahIndexLoader.ts +++ b/src/js/loaders/SurahIndexLoader.ts @@ -1,8 +1,7 @@ import postman, { item } from "postman"; -import type { Parcel } from "postman"; import { formatNumber } from "~/lib/t"; -(function () { +(async function () { const docel = document.documentElement; const main: HTMLElement = docel.querySelector(".postman.main")!; const css: HTMLStyleElement = docel.querySelector(".postman.css")!; @@ -20,7 +19,7 @@ import { formatNumber } from "~/lib/t"; return f; })(); - const delivery = postman( + const parcel = await postman( item.script(`/js/main/vendor.js?v=${rev}`, { id: "0" }), item.script(`/js/main/surah-index.js?v=${rev}`, { id: "1" }), ...fonts, @@ -31,14 +30,12 @@ import { formatNumber } from "~/lib/t"; num.innerText = formatNumber(docel.lang, Number(percent.toFixed(0))); }), ).deliver(); - delivery.then((parcel: Parcel) => { - [main, css].forEach((el) => el.remove()); - parcel.fonts.forEach((f) => document.fonts.add(f)); - parcel.css.forEach((s: HTMLElement) => document.head.appendChild(s)); - parcel.scripts - .sort((a, b) => Number(a.id) - Number(b.id)) - .forEach((s) => { - document.body.removeChild(document.body.appendChild(s)); - }); - }); + [main, css].forEach((el) => el.remove()); + parcel.fonts.forEach((f) => document.fonts.add(f)); + parcel.css.forEach((s: HTMLElement) => document.head.appendChild(s)); + parcel.scripts + .sort((a, b) => Number(a.id) - Number(b.id)) + .forEach((s) => { + document.body.removeChild(document.body.appendChild(s)); + }); })(); diff --git a/src/js/loaders/SurahStreamLoader.ts b/src/js/loaders/SurahStreamLoader.ts index ba91cd6..3bd7c6b 100644 --- a/src/js/loaders/SurahStreamLoader.ts +++ b/src/js/loaders/SurahStreamLoader.ts @@ -1,8 +1,7 @@ import postman, { item } from "postman"; -import type { Parcel } from "postman"; import { formatNumber } from "~/lib/t"; -(function () { +(async function () { const docel = document.documentElement; const main = docel.querySelector(".postman.main")!; const css = docel.querySelector(".postman.css")!; @@ -22,7 +21,7 @@ import { formatNumber } from "~/lib/t"; return f; })(); - const delivery = postman( + const parcel = await postman( item.script(`/js/main/vendor.js?v=${rev}`, { id: "0" }), item.script(`/js/main/surah-stream.js?v=${rev}`, { id: "1" }), ...fonts, @@ -38,15 +37,13 @@ import { formatNumber } from "~/lib/t"; num.innerText = formatNumber(docel.lang, Number(percent.toFixed(0))); }), ).deliver(); - delivery.then((parcel: Parcel) => { - [main, css].forEach((el) => el.remove()); - parcel.fonts.forEach((f) => document.fonts.add(f)); - parcel.css.forEach((s) => document.head.appendChild(s)); - parcel.json.forEach((o) => document.body.appendChild(o)); - parcel.scripts - .sort((a, b) => Number(a.id) - Number(b.id)) - .forEach((s) => { - document.body.removeChild(document.body.appendChild(s)); - }); - }); + [main, css].forEach((el) => el.remove()); + parcel.fonts.forEach((f) => document.fonts.add(f)); + parcel.css.forEach((s) => document.head.appendChild(s)); + parcel.json.forEach((o) => document.body.appendChild(o)); + parcel.scripts + .sort((a, b) => Number(a.id) - Number(b.id)) + .forEach((s) => { + document.body.removeChild(document.body.appendChild(s)); + }); })();