@siladev/qalam 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { Q as o, a as Q } from "../QalamEditor-DlA4iLRR.js";
1
+ import { Q as o, a as Q } from "../QalamEditor-BV95C4EV.js";
2
2
  export {
3
3
  o as QalamEditor,
4
4
  Q as QuranRef
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export * from "./schema";
2
2
  export * from "./editor";
3
3
  export * from "./renderer";
4
4
  export * from "./resolver";
5
+ export * from "./quran";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,18 @@
1
1
  import { validateAST as e } from "./schema/index.js";
2
- import { Q as m, a as t } from "./QalamEditor-DlA4iLRR.js";
3
- import { Q } from "./QalamRenderer-CMsfcF02.js";
4
- import { resolveAST as p } from "./resolver/index.js";
2
+ import { Q as s, a as t } from "./QalamEditor-BV95C4EV.js";
3
+ import { Q as f } from "./QalamRenderer-CMsfcF02.js";
4
+ import { resolveAST as d } from "./resolver/index.js";
5
+ import { g as Q, a as p, b as u, i as S, l as g, r as i } from "./lookup-CFbcujyG.js";
5
6
  export {
6
- m as QalamEditor,
7
- Q as QalamRenderer,
7
+ s as QalamEditor,
8
+ f as QalamRenderer,
8
9
  t as QuranRef,
9
- p as resolveAST,
10
+ Q as getAllSurahs,
11
+ p as getSurahInfo,
12
+ u as getVerseText,
13
+ S as isDataLoaded,
14
+ g as loadQuranData,
15
+ d as resolveAST,
16
+ i as resolveSurah,
10
17
  e as validateAST
11
18
  };
@@ -1,4 +1,4 @@
1
- const S = [
1
+ const E = [
2
2
  {
3
3
  n: 1,
4
4
  na: "الفَاتِحة",
@@ -684,55 +684,102 @@ const S = [
684
684
  ac: 6
685
685
  }
686
686
  ];
687
- let z = null;
688
- function y(a) {
687
+ let b = null, h = null, i = null;
688
+ function Q(a) {
689
+ return a.replace(/[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/g, "");
690
+ }
691
+ function M(a) {
692
+ let n = Q(a.trim());
693
+ return n = n.replace(/[أإآٱ]/g, "ا"), n = n.replace(/ة/g, "ه"), n = n.replace(/ى/g, "ي"), n = n.replace(/^ال/, ""), n;
694
+ }
695
+ function p(a) {
689
696
  return a.toString().replace(/\d/g, (n) => "٠١٢٣٤٥٦٧٨٩"[parseInt(n)]);
690
697
  }
691
- function I(a) {
698
+ function T(a) {
699
+ b = a, h = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
700
+ for (const n of a)
701
+ h.set(n.n, n), i.set(n.na, n), i.set(M(n.na), n);
702
+ }
703
+ function w() {
704
+ return b !== null;
705
+ }
706
+ function x(a) {
707
+ if (!h || !i) return null;
708
+ const n = parseInt(a);
709
+ if (!isNaN(n) && n >= 1 && n <= 114)
710
+ return h.get(n) || null;
711
+ const e = i.get(a);
712
+ if (e) return e;
713
+ const A = M(a), c = i.get(A);
714
+ if (c) return c;
715
+ for (const s of b)
716
+ if (M(s.na).includes(A) || A.includes(M(s.na)))
717
+ return s;
692
718
  return null;
693
719
  }
694
- function p(a, n, t, u, A, d) {
695
- const e = u ?? n, i = [];
696
- for (let s = n; s <= e; s++) {
697
- const h = a.a[s];
698
- if (!h) continue;
699
- const r = h[d];
700
- let o = 0, l = r.length;
701
- s === n && t !== null && t > 0 && (o = t - 1), s === e && A !== null && A > 0 && (l = A), i.push(...r.slice(o, l));
702
- const f = s === e;
703
- (l === r.length || !f) && i.push(h.m);
720
+ function S(a, n, e, A, c, s) {
721
+ const l = A ?? n, o = [];
722
+ for (let r = n; r <= l; r++) {
723
+ const f = a.a[r];
724
+ if (!f) continue;
725
+ const m = f[s];
726
+ let y = 0, u = m.length;
727
+ r === n && e !== null && e > 0 && (y = e - 1), r === l && c !== null && c > 0 && (u = c), o.push(...m.slice(y, u));
728
+ const g = r === l;
729
+ (u === m.length || !g) && o.push(f.m);
704
730
  }
705
- return i;
731
+ return o;
706
732
  }
707
- function x(a, n, t, u, A, d = !1) {
708
- const e = typeof a == "number" ? z?.get(a) : I();
709
- if (!e) return null;
710
- const i = p(e, n, t, u, A, "u"), s = p(e, n, t, u, A, "h"), h = d && e.n !== 1, r = i.join(" "), o = s.join(" "), l = u ?? n, f = [];
711
- for (let c = n; c <= l; c++) {
712
- const m = e.a[c];
713
- if (!m) continue;
714
- const g = m.u;
715
- let q = 0, M = g.length;
716
- c === n && t !== null && t > 0 && (q = t - 1), c === l && A !== null && A > 0 && (M = A), f.push(...g.slice(q, M)), (M === g.length || c !== l) && f.push(`(${y(c)})`);
733
+ function C(a, n, e, A, c, s = !1) {
734
+ const l = typeof a == "number" ? h?.get(a) : x(a);
735
+ if (!l) return null;
736
+ const o = S(l, n, e, A, c, "u"), r = S(l, n, e, A, c, "h"), f = s && l.n !== 1, m = o.join(" "), y = r.join(" "), u = A ?? n, g = [];
737
+ for (let t = n; t <= u; t++) {
738
+ const d = l.a[t];
739
+ if (!d) continue;
740
+ const q = d.u;
741
+ let F = 0, N = q.length;
742
+ t === n && e !== null && e > 0 && (F = e - 1), t === u && c !== null && c > 0 && (N = c), g.push(...q.slice(F, N)), (N === q.length || t !== u) && g.push(`(${p(t)})`);
717
743
  }
718
- const b = f.join(" "), j = [];
719
- for (let c = n; c <= l; c++) {
720
- const m = e.a[c];
721
- m && j.push(m.e);
744
+ const j = g.join(" "), D = [];
745
+ for (let t = n; t <= u; t++) {
746
+ const d = l.a[t];
747
+ d && D.push(d.e);
722
748
  }
723
- const F = j.join(" "), N = n === l ? y(n) : `${y(n)}-${y(l)}`, k = `${e.na}: ${N}`;
724
- return { text: r, textHafsSmart: o, textCopy: b, textEmlaey: F, citation: k, basmalah: h };
749
+ const z = D.join(" "), k = n === u ? p(n) : `${p(n)}-${p(u)}`, I = `${l.na}: ${k}`;
750
+ return { text: m, textHafsSmart: y, textCopy: j, textEmlaey: z, citation: I, basmalah: f };
751
+ }
752
+ function L() {
753
+ return b ? b.map((a) => ({
754
+ number: a.n,
755
+ nameArabic: a.na,
756
+ nameEnglish: a.ne,
757
+ ayaCount: a.ac
758
+ })) : [];
725
759
  }
726
- function T() {
727
- return S.map((a) => ({
760
+ function $() {
761
+ return E.map((a) => ({
728
762
  number: a.n,
729
763
  nameArabic: a.na,
730
764
  nameEnglish: a.ne,
731
765
  ayaCount: a.ac
732
766
  }));
733
767
  }
768
+ function H(a) {
769
+ const n = h?.get(a);
770
+ return n ? {
771
+ number: n.n,
772
+ nameArabic: n.na,
773
+ nameEnglish: n.ne,
774
+ ayaCount: n.ac
775
+ } : null;
776
+ }
734
777
  export {
735
- x as a,
736
- T as g,
737
- I as r
778
+ H as a,
779
+ C as b,
780
+ $ as c,
781
+ L as g,
782
+ w as i,
783
+ T as l,
784
+ x as r
738
785
  };
@@ -1,4 +1,4 @@
1
- import { a as d } from "../lookup-C2v6jsEw.js";
1
+ import { b as d } from "../lookup-CFbcujyG.js";
2
2
  function s(t) {
3
3
  return t.toString().replace(/\d/g, (n) => "٠١٢٣٤٥٦٧٨٩"[parseInt(n)]);
4
4
  }