diff --git a/.gitignore b/.gitignore
index 966f29e..a9a0d7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
/build/
/tmp/
+/packages/typescript/**/*.js
+/packages/typescript/**/dist/
/rake/tasks/deploy.rake
/.gems/
/crash.log
diff --git a/nanoc/lib/mixin/inline.rb b/nanoc/lib/mixin/inline.rb
index f9f9361..3c3fe51 100644
--- a/nanoc/lib/mixin/inline.rb
+++ b/nanoc/lib/mixin/inline.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
module Mixin::Inline
- def inline_json(path)
- class_name = File.basename(path, File.extname(path))
+ def inline_json(path, class_name: File.basename(path, File.extname(path)))
""
diff --git a/package-lock.json b/package-lock.json
index 143bf03..d5498ed 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3828,6 +3828,10 @@
}
]
},
+ "node_modules/Quran": {
+ "resolved": "packages/typescript/Quran",
+ "link": true
+ },
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@@ -4888,6 +4892,20 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.36.tgz",
"integrity": "sha512-8egDX8dE50XyXWH6C6PRCNkTP106DuUrvdrednFouDSmCi7IOvrqr0frznfZaHifHH/3aq/7a7v9N4wdXMqhBQ==",
"dev": true
+ },
+ "packages/typescript/Quran": {
+ "version": "0.1.0",
+ "license": "0BSDL",
+ "devDependencies": {
+ "@types/node": "^16.18",
+ "typescript": "^4.5"
+ }
+ },
+ "packages/typescript/Quran/node_modules/@types/node": {
+ "version": "16.18.96",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.96.tgz",
+ "integrity": "sha512-84iSqGXoO+Ha16j8pRZ/L90vDMKX04QTYMTfYeE1WrjWaZXuchBehGUZEpNgx7JnmlrIHdnABmpjrQjhCnNldQ==",
+ "dev": true
}
},
"dependencies": {
@@ -7508,6 +7526,21 @@
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"dev": true
},
+ "Quran": {
+ "version": "file:packages/typescript/Quran",
+ "requires": {
+ "@types/node": "^16.18",
+ "typescript": "^4.5"
+ },
+ "dependencies": {
+ "@types/node": {
+ "version": "16.18.96",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.96.tgz",
+ "integrity": "sha512-84iSqGXoO+Ha16j8pRZ/L90vDMKX04QTYMTfYeE1WrjWaZXuchBehGUZEpNgx7JnmlrIHdnABmpjrQjhCnNldQ==",
+ "dev": true
+ }
+ }
+ },
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
diff --git a/packages/typescript/Quran/package.json b/packages/typescript/Quran/package.json
new file mode 100644
index 0000000..351090e
--- /dev/null
+++ b/packages/typescript/Quran/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "Quran",
+ "version": "0.1.0",
+ "description": "The Noble Quran: a programmer's interface",
+ "main": "dist/index.js",
+ "types": ["dist/index.d.ts"],
+ "scripts": {
+ "build": "npm exec tsc",
+ "prepare": "npm run build"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/ReflectsLight/al-quran.reflectslight.io.git"
+ },
+ "author": "0x1eef",
+ "license": "0BSDL",
+ "devDependencies": {
+ "@types/node": "^16.18",
+ "typescript": "^4.5"
+ }
+}
diff --git a/packages/typescript/Quran/src/index.ts b/packages/typescript/Quran/src/index.ts
new file mode 100644
index 0000000..652e89c
--- /dev/null
+++ b/packages/typescript/Quran/src/index.ts
@@ -0,0 +1,72 @@
+type TLocale = "ar" | "en";
+type TAyat = Ayah[];
+type TQuran = {
+ locale: TLocale;
+ surahs: Surah[];
+}
+type TSurah = {
+ readonly id: number;
+ readonly name: string;
+ readonly numberOfAyah: number;
+ readonly romanized: { name: string; slug: string };
+ readonly utf8: { codepoints: number[] };
+};
+type TAyah = {
+ id: number;
+ body: string;
+}
+
+class Quran {
+ locale: TLocale;
+ surahs: Surah[];
+
+ constructor(self: T) {
+ this.locale = self.locale;
+ this.surahs = self.surahs;
+ }
+}
+
+class Surah {
+ readonly id: number;
+ readonly name: string;
+ readonly numberOfAyah: number;
+ readonly romanized: { name: string; slug: string };
+ readonly utf8: { codepoints: number[] };
+ readonly ayat: TAyat
+
+ constructor(self: T) {
+ this.id = self.id;
+ this.name = self.name;
+ this.numberOfAyah = self.numberOfAyah;
+ this.romanized = self.romanized;
+ this.utf8 = self.utf8;
+ this.ayat = [];
+ return this;
+ }
+
+ getName(locale: TLocale): string {
+ if (locale === "ar") {
+ return String.fromCodePoint(...this.utf8.codepoints);
+ } else {
+ return this.name;
+ }
+ }
+}
+
+class Ayah {
+ readonly id: number;
+ readonly body: string;
+ ms: number;
+
+ constructor(self: T) {
+ this.id = self.id;
+ this.body = self.body;
+ this.ms = 0;
+ }
+}
+
+export {
+ Quran, Surah, Ayah,
+ TQuran, TSurah, TAyah,
+ TAyat, TLocale
+};
diff --git a/packages/typescript/Quran/tsconfig.json b/packages/typescript/Quran/tsconfig.json
new file mode 100644
index 0000000..a6e6cb2
--- /dev/null
+++ b/packages/typescript/Quran/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "strict": true,
+ "module": "ESNEXT",
+ "target": "ES2020",
+ "esModuleInterop": true,
+ "moduleResolution": "node",
+
+ "baseUrl": "src/",
+ "paths": { "*": ["*"] },
+
+ "outDir": "dist",
+ "declaration": true,
+ }
+}
diff --git a/src/html/stream.html.erb b/src/html/stream.html.erb
index 246190c..99a60b8 100644
--- a/src/html/stream.html.erb
+++ b/src/html/stream.html.erb
@@ -34,7 +34,7 @@
data-surah-id="<%= context.surah.id %>">
<%= inline_json("/json/i18n.json") %>
- <%= inline_json("/json/recitations.json") %>
+ <%= inline_json("/json/durations/alafasy/#{context.surah.id}.json", class_name: 'durations') %>