lipilekhika 0.0.1-beta.4 → 1.0.0
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.
- package/README.md +26 -1
- package/dist/cjs/{Devanagari-DpTFxWzf.cjs → Devanagari-CubB6Ubb.cjs} +1 -1
- package/dist/cjs/{Purna-Devanagari-D3oMLWVK.cjs → Purna-Devanagari-72KHauTF.cjs} +1 -1
- package/dist/cjs/{Romanized-CORlHeSC.cjs → Romanized-Dy_qfDqa.cjs} +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{script_normalization-CspIwSEH.cjs → script_normalization-BlG9S8Ex.cjs} +1 -1
- package/dist/cjs/typing.cjs +1 -1
- package/dist/esm/{Devanagari-Dc-GEsix.js → Devanagari-C4NmXCKb.js} +1 -1
- package/dist/esm/{Purna-Devanagari-CpqQcLu_.js → Purna-Devanagari-CqkVL5zc.js} +1 -1
- package/dist/esm/{Romanized-CAwj04a2.js → Romanized-CQkrk7RV.js} +3 -3
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/{script_normalization-CORXzSdg.js → script_normalization-D8Eu1NYy.js} +1 -1
- package/dist/esm/typing.mjs +135 -78
- package/dist/lipilekhika.umd.js +2 -2
- package/dist/typing.d.ts +25 -0
- package/dist/umd_json/script_data/Devanagari.json +1 -1
- package/dist/umd_json/script_data/Purna-Devanagari.json +1 -1
- package/dist/umd_json/script_data/Romanized.json +1 -1
- package/package.json +8 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const a = "other", l = "Romanized", e = 12, h = "a", n = [[".", { krama: [115], next: ["."] }], ["..", { krama: [116] }], ["C", { krama: [61], next: ["h"] }], ["Ch", { krama: [62] }], ["L", { next: ["̥"] }], ["L̥", { krama: [41], next: ["̄"] }], ["L̥̄", { krama: [43] }], ["M", { next: ["̐"] }], ["M̐", { krama: [46] }], ["R", { next: ["̥"] }], ["R̥", { krama: [37], next: ["̄"] }], ["R̥̄", { krama: [39] }], ["a", { krama: [1], next: ["i", "u"] }], ["ai", { krama: [25] }], ["au", { krama: [33] }], ["b", { krama: [85], next: ["h"] }], ["bh", { krama: [87] }], ["c", { next: ["h"] }], ["ch", { krama: [61], next: ["h"] }], ["chh", { krama: [62] }], ["d", { krama: [70], next: ["h"] }], ["dh", { krama: [71] }], ["g", { krama: [56], next: ["z", "h"] }], ["gh", { krama: [59] }], ["gz", { krama: [57] }], ["j", { krama: [63], next: ["z", "h"] }], ["jh", { krama: [66] }], ["jz", { krama: [64] }], ["k", { krama: [52], next: ["z", "h"] }], ["kh", { krama: [54], next: ["z"] }], ["khz", { krama: [55] }], ["kz", { krama: [53] }], ["l", { krama: [94], next: ["̥"] }], ["l̥", { krama: [41], next: ["̄"] }], ["l̥̄", { krama: [43] }], ["m", { krama: [88], next: ["̐"] }], ["m̐", { krama: [46] }], ["p", { krama: [82], next: ["h"] }], ["ph", { krama: [83], next: ["z"] }], ["phz", { krama: [84] }], ["r", { krama: [92], next: ["̥"] }], ["r̥", { krama: [37], next: ["̄"] }], ["r̥̄", { krama: [39] }], ["t", { krama: [68], next: ["h"] }], ["th", { krama: [69] }], ["Ê", { krama: [27] }], ["Ñ", { krama: [67] }], ["Ô", { krama: [35] }], ["Ā", { krama: [5] }], ["ā", { krama: [5], next: ["ū"] }], ["āū", { krama: [5, 17], next: ["ṁ"] }], ["āūṁ", { krama: [0] }], ["Ē", { krama: [21] }], ["Ī", { krama: [11] }], ["Ō", { krama: [29] }], ["Ś", { krama: [99] }], ["Ū", { krama: [17] }], ["Ḍ", { krama: [76], next: ["h"] }], ["Ḍh", { krama: [79] }], ["ḍ", { krama: [76], next: ["h"] }], ["ḍh", { krama: [79] }], ["Ḥ", { krama: [47] }], ["Ḷ", { krama: [95] }], ["Ḻ", { krama: [96] }], ["Ṁ", { krama: [45] }], ["Ṅ", { krama: [81] }], ["Ṇ", { krama: [81] }], ["Ṉ", { krama: [73] }], ["Ṛ", { krama: [77], next: ["h"] }], ["Ṛh", { krama: [80] }], ["ṛ", { krama: [77], next: ["h"] }], ["ṛh", { krama: [80] }], ["Ṟ", { krama: [93] }], ["Ṣ", { krama: [100] }], ["Ṭ", { krama: [74], next: ["h"] }], ["Ṭh", { krama: [75] }], ["ṭ", { krama: [74], next: ["h"] }], ["ṭh", { krama: [75] }], ["↑", { krama: [102], next: ["↑"] }], ["↑↑", { krama: [103], next: ["↑"] }], ["↑↑↑", { krama: [104] }]], r = [], k = [["āūṁ", null], ["a", null], ["a", null], ["a", null], ["a", null], ["ā", null], ["ā", null], ["ā", null], ["ā", null], ["i", null], ["i", null], ["ī", null], ["ī", null], ["u", null], ["u", null], ["u", null], ["u", null], ["ū", null], ["ū", null], ["ū", null], ["ū", null], ["ē", null], ["ē", null], ["e", null], ["e", null], ["ai", null], ["ai", null], ["ê", null], ["ê", null], ["ō", null], ["ō", null], ["o", null], ["o", null], ["au", null], ["au", null], ["ô", null], ["ô", null], ["r̥", null], ["r̥", null], ["r̥̄", null], ["r̥̄", null], ["l̥", null], ["l̥", null], ["l̥̄", null], ["l̥̄", null], ["ṁ", null], ["m̐", null], ["ḥ", null], ["`", null], ["", null], ["", null], ["", null], ["k", null], ["kz", null], ["kh", null], ["khz", null], ["g", null], ["gz", null], ["g", null], ["gh", null], ["ṅ", null], ["C", null], ["Ch", null], ["j", null], ["jz", null], ["j", null], ["jh", null], ["ñ", null], ["t", null], ["th", null], ["d", null], ["dh", null], ["n", null], ["ṉ", null], ["ṭ", null], ["ṭh", null], ["ḍ", null], ["ṛ", null], ["ḍ", null], ["ḍh", null], ["ṛh", null], ["ṇ", null], ["p", null], ["ph", null], ["phz", null], ["b", null], ["b", null], ["bh", null], ["m", null], ["y", null], ["y", null], ["v", null], ["r", null], ["ṟ", null], ["l", null], ["ḷ", null], ["ḻ", null], ["h", null], ["s", null], ["ś", null], ["ṣ", null], ["↓", null], ["↑", null], ["↑↑", null], ["↑↑↑", null], ["0", null], ["1", null], ["2", null], ["3", null], ["4", null], ["5", null], ["6", null], ["7", null], ["8", null], ["9", null], [".", null], ["..", null]], m = [49, 50, 51, 115, 116, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 61, 62, 48, 1, 2, 3, 4, 25, 26, 33, 34, 85, 86, 87, 70, 71, 23, 24, 56, 58, 59, 57, 97, 9, 10, 63, 65, 66, 64, 52, 54, 55, 53, 94, 41, 42, 43, 44, 88, 46, 72, 31, 32, 82, 83, 84, 92, 37, 38, 39, 40, 98, 68, 69, 13, 14, 15, 16, 91, 89, 90, 27, 28, 67, 35, 36, 5, 6, 7, 8, 0, 21, 22, 11, 12, 29, 30, 99, 17, 18, 19, 20, 76, 78, 79, 47, 95, 96, 45, 60, 81, 73, 77, 80, 93, 100, 74, 75, 102, 103, 104, 101], u = [["'", { next: ["'"], krama: [102] }], ["''", { next: ["'"], krama: [103] }], ["'''", { krama: [104] }], [".", { krama: [115], next: [".", "q", "h", "A", "i", "I", "u", "U", "e", "E", "a", "O", "o", "R", "L"] }], ["..", { krama: [116] }], [".A", { krama: [6], next: ["1"] }], [".A1", { krama: [8] }], [".E", { krama: [22] }], [".I", { krama: [12] }], [".L", { next: ["R"], krama: [2, 95] }], [".LR", { krama: [42], next: ["R"] }], [".LRR", { krama: [44] }], [".O", { krama: [30] }], [".R", { krama: [38], next: ["R"] }], [".RR", { krama: [40] }], [".U", { krama: [18], next: ["1"] }], [".U1", { krama: [20] }], [".a", { next: ["i", "u"], krama: [2, 2] }], [".ai", { next: ["I"], krama: [2, 2, 2] }], [".aiI", { krama: [28] }], [".au", { next: ["U"], krama: [2, 2, 2] }], [".auU", { krama: [36] }], [".e", { krama: [24] }], [".h", { krama: [49] }], [".i", { krama: [10] }], [".o", { krama: [32] }], [".q", { custom_back_ref: 3 }], [".u", { krama: [14], next: ["1"] }], [".u1", { krama: [16] }], [";", { krama: [48] }], ["A", { krama: [5], next: ["U"] }], ["AU", { krama: [5, 17], next: ["M"] }], ["AUM", { krama: [0] }], ["C", { krama: [61], next: ["h"] }], ["Ch", { krama: [62] }], ["D", { krama: [76], next: ["z", "h"] }], ["Dh", { krama: [79], next: ["z"] }], ["Dhz", { krama: [80] }], ["Dz", { krama: [77] }], ["L", { krama: [95], next: ["R", "z"] }], ["LR", { krama: [41], next: ["R"] }], ["LRR", { krama: [43] }], ["Lz", { krama: [96] }], ["M", { krama: [45], next: ["M"] }], ["MM", { krama: [46] }], ["Q", { krama: [51], next: ["Q"] }], ["QQ", { custom_back_ref: 1 }], ["R", { krama: [37], next: ["R"] }], ["RR", { krama: [39] }], ["S", { krama: [-1], next: ["h"] }], ["Sh", { krama: [100] }], ["T", { krama: [74], next: ["h"] }], ["Th", { krama: [75] }], ["_", { krama: [101] }], ["a", { krama: [1], next: ["i", "u", "a"] }], ["aa", { krama: [5] }], ["ai", { krama: [25] }], ["au", { krama: [33] }], ["b", { krama: [85], next: ["h"] }], ["bh", { krama: [87] }], ["c", { next: ["h"] }], ["ch", { krama: [61], next: ["h"] }], ["chh", { krama: [62] }], ["d", { krama: [70], next: ["h"] }], ["dh", { krama: [71] }], ["e", { next: ["e"], krama: [23] }], ["ee", { krama: [11] }], ["f", { krama: [84] }], ["g", { krama: [56], next: ["z", "h"] }], ["gh", { krama: [59] }], ["gz", { krama: [57] }], ["i", { next: ["i"], krama: [9] }], ["ii", { krama: [11] }], ["j", { krama: [63], next: ["z", "h"] }], ["jh", { krama: [66] }], ["jz", { krama: [64] }], ["k", { krama: [52], next: ["z", "h"] }], ["kh", { krama: [54], next: ["z"] }], ["khz", { krama: [55] }], ["kz", { krama: [53] }], ["n", { krama: [72], next: ["z", "1"] }], ["n1", { krama: [73] }], ["nz", { krama: [73] }], ["o", { next: ["o"], krama: [31] }], ["oo", { krama: [17] }], ["p", { krama: [82], next: ["h"] }], ["ph", { krama: [83], next: ["z"] }], ["phz", { krama: [84] }], ["q", { custom_back_ref: 0, next: ["q"] }], ["qq", { custom_back_ref: 2 }], ["r", { krama: [92], next: ["z", "1"] }], ["r1", { krama: [93] }], ["rz", { krama: [93] }], ["s", { krama: [98], next: ["h"] }], ["sh", { krama: [99] }], ["t", { krama: [68], next: ["h"] }], ["th", { krama: [69] }], ["u", { next: ["u"], krama: [13] }], ["uu", { krama: [17] }], ["z", { krama: [64], next: ["h"] }], ["zh", { krama: [96] }], ["↑", { krama: [102], next: ["↑"] }], ["↑↑", { krama: [103], next: ["↑"] }], ["↑↑↑", { krama: [104] }]], t = [["", null, 88], ["Q", null, 46], ["q", null, 89], ["", null, 26]], x = {
|
|
1
|
+
const a = "other", l = "Romanized", e = 12, x = "a", n = [[".", { krama: [115], next: ["."] }], ["..", { krama: [116] }], ["C", { krama: [61], next: ["h"] }], ["Ch", { krama: [62] }], ["L", { next: ["̥"] }], ["L̥", { krama: [41], next: ["̄"] }], ["L̥̄", { krama: [43] }], ["M", { next: ["̐"] }], ["M̐", { krama: [46] }], ["R", { next: ["̥"] }], ["R̥", { krama: [37], next: ["̄"] }], ["R̥̄", { krama: [39] }], ["a", { krama: [1], next: ["i", "u"] }], ["ai", { krama: [25] }], ["au", { krama: [33] }], ["b", { krama: [85], next: ["h"] }], ["bh", { krama: [87] }], ["c", { next: ["h"] }], ["ch", { krama: [61], next: ["h"] }], ["chh", { krama: [62] }], ["d", { krama: [70], next: ["h"] }], ["dh", { krama: [71] }], ["g", { krama: [56], next: ["z", "h"] }], ["gh", { krama: [59] }], ["gz", { krama: [57] }], ["j", { krama: [63], next: ["z", "h"] }], ["jh", { krama: [66] }], ["jz", { krama: [64] }], ["k", { krama: [52], next: ["z", "h"] }], ["kh", { krama: [54], next: ["z"] }], ["khz", { krama: [55] }], ["kz", { krama: [53] }], ["l", { krama: [94], next: ["̥"] }], ["l̥", { krama: [41], next: ["̄"] }], ["l̥̄", { krama: [43] }], ["m", { krama: [88], next: ["̐"] }], ["m̐", { krama: [46] }], ["p", { krama: [82], next: ["h"] }], ["ph", { krama: [83], next: ["z"] }], ["phz", { krama: [84] }], ["r", { krama: [92], next: ["̥"] }], ["r̥", { krama: [37], next: ["̄"] }], ["r̥̄", { krama: [39] }], ["t", { krama: [68], next: ["h"] }], ["th", { krama: [69] }], ["Ê", { krama: [27] }], ["Ñ", { krama: [67] }], ["Ô", { krama: [35] }], ["Ā", { krama: [5] }], ["ā", { krama: [5], next: ["ū"] }], ["āū", { krama: [5, 17], next: ["ṁ"] }], ["āūṁ", { krama: [0] }], ["Ē", { krama: [21] }], ["Ī", { krama: [11] }], ["Ō", { krama: [29] }], ["Ś", { krama: [99] }], ["Ū", { krama: [17] }], ["Ḍ", { krama: [76], next: ["h"] }], ["Ḍh", { krama: [79] }], ["ḍ", { krama: [76], next: ["h"] }], ["ḍh", { krama: [79] }], ["Ḥ", { krama: [47] }], ["Ḷ", { krama: [95] }], ["Ḻ", { krama: [96] }], ["Ṁ", { krama: [45] }], ["Ṅ", { krama: [60] }], ["Ṇ", { krama: [81] }], ["Ṉ", { krama: [73] }], ["Ṛ", { krama: [77], next: ["h"] }], ["Ṛh", { krama: [80] }], ["ṛ", { krama: [77], next: ["h"] }], ["ṛh", { krama: [80] }], ["Ṟ", { krama: [93] }], ["Ṣ", { krama: [100] }], ["Ṭ", { krama: [74], next: ["h"] }], ["Ṭh", { krama: [75] }], ["ṭ", { krama: [74], next: ["h"] }], ["ṭh", { krama: [75] }], ["↑", { krama: [102], next: ["↑"] }], ["↑↑", { krama: [103], next: ["↑"] }], ["↑↑↑", { krama: [104] }]], r = [], k = [["āūṁ", null], ["a", null], ["a", null], ["a", null], ["a", null], ["ā", null], ["ā", null], ["ā", null], ["ā", null], ["i", null], ["i", null], ["ī", null], ["ī", null], ["u", null], ["u", null], ["u", null], ["u", null], ["ū", null], ["ū", null], ["ū", null], ["ū", null], ["ē", null], ["ē", null], ["e", null], ["e", null], ["ai", null], ["ai", null], ["ê", null], ["ê", null], ["ō", null], ["ō", null], ["o", null], ["o", null], ["au", null], ["au", null], ["ô", null], ["ô", null], ["r̥", null], ["r̥", null], ["r̥̄", null], ["r̥̄", null], ["l̥", null], ["l̥", null], ["l̥̄", null], ["l̥̄", null], ["ṁ", null], ["m̐", null], ["ḥ", null], ["`", null], ["", null], ["", null], ["", null], ["k", null], ["kz", null], ["kh", null], ["khz", null], ["g", null], ["gz", null], ["g", null], ["gh", null], ["ṅ", null], ["C", null], ["Ch", null], ["j", null], ["jz", null], ["j", null], ["jh", null], ["ñ", null], ["t", null], ["th", null], ["d", null], ["dh", null], ["n", null], ["ṉ", null], ["ṭ", null], ["ṭh", null], ["ḍ", null], ["ṛ", null], ["ḍ", null], ["ḍh", null], ["ṛh", null], ["ṇ", null], ["p", null], ["ph", null], ["phz", null], ["b", null], ["b", null], ["bh", null], ["m", null], ["y", null], ["y", null], ["v", null], ["r", null], ["ṟ", null], ["l", null], ["ḷ", null], ["ḻ", null], ["h", null], ["s", null], ["ś", null], ["ṣ", null], ["↓", null], ["↑", null], ["↑↑", null], ["↑↑↑", null], ["0", null], ["1", null], ["2", null], ["3", null], ["4", null], ["5", null], ["6", null], ["7", null], ["8", null], ["9", null], [".", null], ["..", null]], m = [49, 50, 51, 115, 116, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 61, 62, 48, 1, 2, 3, 4, 25, 26, 33, 34, 85, 86, 87, 70, 71, 23, 24, 56, 58, 59, 57, 97, 9, 10, 63, 65, 66, 64, 52, 54, 55, 53, 94, 41, 42, 43, 44, 88, 46, 72, 31, 32, 82, 83, 84, 92, 37, 38, 39, 40, 98, 68, 69, 13, 14, 15, 16, 91, 89, 90, 27, 28, 67, 35, 36, 5, 6, 7, 8, 0, 21, 22, 11, 12, 29, 30, 99, 17, 18, 19, 20, 76, 78, 79, 47, 95, 96, 45, 60, 81, 73, 77, 80, 93, 100, 74, 75, 102, 103, 104, 101], u = [["'", { next: ["'"], krama: [102] }], ["''", { next: ["'"], krama: [103] }], ["'''", { krama: [104] }], [".", { krama: [115], next: [".", "q", "h", "A", "i", "I", "u", "U", "e", "E", "a", "O", "o", "R", "L"] }], ["..", { krama: [116] }], [".A", { krama: [6], next: ["1"] }], [".A1", { krama: [8] }], [".E", { krama: [22] }], [".I", { krama: [12] }], [".L", { next: ["R"], krama: [2, 95] }], [".LR", { krama: [42], next: ["R"] }], [".LRR", { krama: [44] }], [".O", { krama: [30] }], [".R", { krama: [38], next: ["R"] }], [".RR", { krama: [40] }], [".U", { krama: [18], next: ["1"] }], [".U1", { krama: [20] }], [".a", { next: ["i", "u"], krama: [2, 2] }], [".ai", { next: ["I"], krama: [2, 2, 2] }], [".aiI", { krama: [28] }], [".au", { next: ["U"], krama: [2, 2, 2] }], [".auU", { krama: [36] }], [".e", { krama: [24] }], [".h", { krama: [49] }], [".i", { krama: [10] }], [".o", { krama: [32] }], [".q", { custom_back_ref: 32 }], [".u", { krama: [14], next: ["1"] }], [".u1", { krama: [16] }], [";", { krama: [48] }], ["A", { krama: [5], next: ["U", "^"] }], ["AU", { krama: [5, 17], next: ["M"] }], ["AUM", { krama: [0] }], ["A^", { custom_back_ref: 11 }], ["C", { krama: [61], next: ["h"] }], ["Ch", { krama: [62] }], ["D", { krama: [76], next: ["z", "h", "^"] }], ["D^", { custom_back_ref: 17 }], ["Dh", { krama: [79], next: ["z", "^"] }], ["Dh^", { custom_back_ref: 18 }], ["Dhz", { krama: [80], next: ["^"] }], ["Dhz^", { custom_back_ref: 27 }], ["Dz", { krama: [77], next: ["^"] }], ["Dz^", { custom_back_ref: 26 }], ["E", { next: ["^"], krama: [21] }], ["E^", { custom_back_ref: 12 }], ["G", { next: ["^"], krama: [60] }], ["G^", { custom_back_ref: 23 }], ["H", { next: ["^"], krama: [47] }], ["H^", { custom_back_ref: 19 }], ["I", { next: ["^"], krama: [11] }], ["I^", { custom_back_ref: 13 }], ["J", { next: ["^"], krama: [67] }], ["J^", { custom_back_ref: 9 }], ["L", { krama: [95], next: ["R", "z", "^"] }], ["LR", { krama: [41], next: ["R", "^"] }], ["LRR", { krama: [43], next: ["^"] }], ["LRR^", { custom_back_ref: 2 }], ["LR^", { custom_back_ref: 1 }], ["L^", { custom_back_ref: 20 }], ["Lz", { krama: [96], next: ["^"] }], ["Lz^", { custom_back_ref: 21 }], ["M", { krama: [45], next: ["M", "^"] }], ["MM", { krama: [46], next: ["^"] }], ["MM^", { custom_back_ref: 3 }], ["M^", { custom_back_ref: 22 }], ["N", { next: ["^"], krama: [81] }], ["N^", { custom_back_ref: 24 }], ["O", { next: ["^"], krama: [29] }], ["O^", { custom_back_ref: 14 }], ["Q", { krama: [51], next: ["Q"] }], ["QQ", { custom_back_ref: 4 }], ["R", { krama: [37], next: ["R", "^"] }], ["RR", { krama: [39], next: ["^"] }], ["RR^", { custom_back_ref: 6 }], ["R^", { custom_back_ref: 5 }], ["S", { krama: [-1], next: ["h"] }], ["Sh", { krama: [100], next: ["^"] }], ["Sh^", { custom_back_ref: 29 }], ["T", { krama: [74], next: ["h", "^"] }], ["T^", { custom_back_ref: 30 }], ["Th", { krama: [75], next: ["^"] }], ["Th^", { custom_back_ref: 31 }], ["U", { next: ["^"], krama: [17] }], ["U^", { custom_back_ref: 16 }], ["_", { krama: [101] }], ["a", { krama: [1], next: ["i", "u", "a"] }], ["aa", { krama: [5] }], ["ai", { krama: [25], next: ["I"] }], ["aiI", { next: ["^"], krama: [2, 2, 2] }], ["aiI^", { custom_back_ref: 8 }], ["au", { krama: [33], next: ["U"] }], ["auU", { next: ["^"], krama: [2, 2, 2] }], ["auU^", { custom_back_ref: 10 }], ["b", { krama: [85], next: ["h"] }], ["bh", { krama: [87] }], ["c", { next: ["h"] }], ["ch", { krama: [61], next: ["h"] }], ["chh", { krama: [62] }], ["d", { krama: [70], next: ["h"] }], ["dh", { krama: [71] }], ["e", { next: ["e"], krama: [23] }], ["ee", { krama: [11] }], ["f", { krama: [84] }], ["g", { krama: [56], next: ["z", "h"] }], ["gh", { krama: [59] }], ["gz", { krama: [57] }], ["i", { next: ["i"], krama: [9] }], ["ii", { krama: [11] }], ["j", { krama: [63], next: ["z", "h"] }], ["jh", { krama: [66] }], ["jz", { krama: [64] }], ["k", { krama: [52], next: ["z", "h"] }], ["kh", { krama: [54], next: ["z"] }], ["khz", { krama: [55] }], ["kz", { krama: [53] }], ["n", { krama: [72], next: ["z", "1"] }], ["n1", { krama: [73] }], ["nz", { krama: [73], next: ["^"] }], ["nz^", { custom_back_ref: 25 }], ["o", { next: ["o"], krama: [31] }], ["oo", { krama: [17] }], ["p", { krama: [82], next: ["h"] }], ["ph", { krama: [83], next: ["z"] }], ["phz", { krama: [84] }], ["q", { custom_back_ref: 0, next: ["q"] }], ["qq", { custom_back_ref: 7 }], ["r", { krama: [92], next: ["z", "1"] }], ["r1", { krama: [93] }], ["rz", { krama: [93], next: ["^"] }], ["rz^", { custom_back_ref: 28 }], ["s", { krama: [98], next: ["h"] }], ["sh", { krama: [99], next: ["^"] }], ["sh^", { custom_back_ref: 15 }], ["t", { krama: [68], next: ["h"] }], ["th", { krama: [69] }], ["u", { next: ["u"], krama: [13] }], ["uu", { krama: [17] }], ["z", { krama: [64], next: ["h"] }], ["zh", { krama: [96] }], ["↑", { krama: [102], next: ["↑"] }], ["↑↑", { krama: [103], next: ["↑"] }], ["↑↑↑", { krama: [104] }]], t = [["", null, 125], ["L̥", null, 58], ["L̥̄", null, 57], ["M̐", null, 64], ["Q", null, 71], ["R̥", null, 75], ["R̥̄", null, 74], ["q", null, 126], ["Ê", null, 90], ["Ñ", null, 53], ["Ô", null, 93], ["Ā", null, 33], ["Ē", null, 45], ["Ī", null, 51], ["Ō", null, 69], ["Ś", null, 133], ["Ū", null, 84], ["Ḍ", null, 37], ["Ḍh", null, 39], ["Ḥ", null, 49], ["Ḷ", null, 59], ["Ḻ", null, 61], ["Ṁ", null, 65], ["Ṅ", null, 47], ["Ṇ", null, 67], ["Ṉ", null, 119], ["Ṛ", null, 43], ["Ṛh", null, 41], ["Ṟ", null, 130], ["Ṣ", null, 78], ["Ṭ", null, 80], ["Ṭh", null, 82], ["", null, 26]], h = {
|
|
2
2
|
script_type: a,
|
|
3
3
|
script_name: l,
|
|
4
4
|
script_id: 12,
|
|
@@ -12,11 +12,11 @@ const a = "other", l = "Romanized", e = 12, h = "a", n = [[".", { krama: [115],
|
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
14
14
|
t as custom_script_chars_arr,
|
|
15
|
-
|
|
15
|
+
h as default,
|
|
16
16
|
k as krama_text_arr,
|
|
17
17
|
m as krama_text_arr_index,
|
|
18
18
|
r as list,
|
|
19
|
-
|
|
19
|
+
x as schwa_character,
|
|
20
20
|
e as script_id,
|
|
21
21
|
l as script_name,
|
|
22
22
|
a as script_type,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as i, a as e, t as p, b as l, c as m } from "./script_normalization-
|
|
2
|
-
import { A as S, L, S as v } from "./script_normalization-
|
|
1
|
+
import { g as i, a as e, t as p, b as l, c as m } from "./script_normalization-D8Eu1NYy.js";
|
|
2
|
+
import { A as S, L, S as v } from "./script_normalization-D8Eu1NYy.js";
|
|
3
3
|
const d = async (t) => {
|
|
4
4
|
const r = i(t);
|
|
5
5
|
if (!r)
|
|
@@ -23,7 +23,7 @@ const ve = (n, e, l) => {
|
|
|
23
23
|
return t ? typeof t == "function" ? t() : Promise.resolve(t) : new Promise((a, s) => {
|
|
24
24
|
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(s.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + e + (e.split("/").length !== l ? ". Note that variables only represent file names one level deep." : ""))));
|
|
25
25
|
});
|
|
26
|
-
}, le = {}, ue = async (n) => (le[n] || (le[n] = ve(/* @__PURE__ */ Object.assign({ "../script_data/Assamese.json": () => import("./Assamese-4WO2wzXg.js"), "../script_data/Bengali.json": () => import("./Bengali-Dhlxv7Pr.js"), "../script_data/Brahmi.json": () => import("./Brahmi-BvC4Luvf.js"), "../script_data/Devanagari.json": () => import("./Devanagari-
|
|
26
|
+
}, le = {}, ue = async (n) => (le[n] || (le[n] = ve(/* @__PURE__ */ Object.assign({ "../script_data/Assamese.json": () => import("./Assamese-4WO2wzXg.js"), "../script_data/Bengali.json": () => import("./Bengali-Dhlxv7Pr.js"), "../script_data/Brahmi.json": () => import("./Brahmi-BvC4Luvf.js"), "../script_data/Devanagari.json": () => import("./Devanagari-C4NmXCKb.js"), "../script_data/Granth.json": () => import("./Granth-B3US1gHe.js"), "../script_data/Gujarati.json": () => import("./Gujarati-DfQS2sSY.js"), "../script_data/Gurumukhi.json": () => import("./Gurumukhi-dVJRMJNL.js"), "../script_data/Kannada.json": () => import("./Kannada-ZB5P9u4T.js"), "../script_data/Malayalam.json": () => import("./Malayalam-BQROfOnO.js"), "../script_data/Modi.json": () => import("./Modi-B16t9oPJ.js"), "../script_data/Normal.json": () => import("./Normal-Chi5ccip.js"), "../script_data/Odia.json": () => import("./Odia-hd6WA8ll.js"), "../script_data/Purna-Devanagari.json": () => import("./Purna-Devanagari-CqkVL5zc.js"), "../script_data/Romanized.json": () => import("./Romanized-CQkrk7RV.js"), "../script_data/Sharada.json": () => import("./Sharada-Bk4pUPeN.js"), "../script_data/Siddham.json": () => import("./Siddham-Cf9Jp5KF.js"), "../script_data/Sinhala.json": () => import("./Sinhala-C6t7GaP6.js"), "../script_data/Tamil-Extended.json": () => import("./Tamil-Extended-nmDMmVeX.js"), "../script_data/Tamil.json": () => import("./Tamil-CR4VFQvV.js"), "../script_data/Telugu.json": () => import("./Telugu-BCg-EHjf.js") }), `../script_data/${n}.json`, 3).then(
|
|
27
27
|
(e) => e.default
|
|
28
28
|
)), le[n]), J = {
|
|
29
29
|
"all_to_normal:replace_pancham_varga_varna_with_n": { from_script_type: "all", to_script_name: ["Normal"], check_in: "output", rules: [{ type: "replace_prev_krama_keys", check_in: "output", prev: [60], following: [52, 53, 54, 55, 56, 57, 58, 59], replace_with: [72] }, { type: "replace_prev_krama_keys", check_in: "output", prev: [67], following: [61, 62, 63, 64, 65, 66], replace_with: [72] }] },
|
package/dist/esm/typing.mjs
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { g as v, a as x, r as b, d as K } from "./script_normalization-D8Eu1NYy.js";
|
|
2
|
+
const U = 4500, D = !0, I = !1;
|
|
3
|
+
function L(r, n) {
|
|
4
4
|
const { autoContextTClearTimeMs: t } = n ?? {};
|
|
5
|
-
let
|
|
6
|
-
const s =
|
|
5
|
+
let c = n?.useNativeNumerals ?? D, l = n?.includeInherentVowel ?? I;
|
|
6
|
+
const s = v(r);
|
|
7
7
|
if (!s)
|
|
8
8
|
throw new Error(`Invalid script name: ${r}`);
|
|
9
|
-
let
|
|
10
|
-
const
|
|
11
|
-
let o = null,
|
|
12
|
-
const
|
|
13
|
-
const [
|
|
9
|
+
let e = "", a = "";
|
|
10
|
+
const i = t ?? U;
|
|
11
|
+
let o = null, p = null, m = null, f = {}, u = [];
|
|
12
|
+
const _ = (async () => {
|
|
13
|
+
const [E, h] = await Promise.all([
|
|
14
14
|
x("Normal"),
|
|
15
15
|
x(s)
|
|
16
16
|
]);
|
|
17
|
-
|
|
18
|
-
const T =
|
|
19
|
-
|
|
17
|
+
p = E, m = h;
|
|
18
|
+
const T = b(E, h);
|
|
19
|
+
f = T.trans_options, u = T.custom_rules;
|
|
20
20
|
})();
|
|
21
|
-
function
|
|
22
|
-
o = null,
|
|
21
|
+
function d() {
|
|
22
|
+
o = null, e = "", a = "";
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
if (!
|
|
24
|
+
function y(E) {
|
|
25
|
+
if (!p || !m)
|
|
26
26
|
throw new Error(
|
|
27
27
|
"Typing context not ready. Await `ctx.ready` before calling takeKeyInputSync."
|
|
28
28
|
);
|
|
29
|
-
const
|
|
30
|
-
o &&
|
|
31
|
-
let T =
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
const { context_length:
|
|
35
|
-
|
|
29
|
+
const h = Date.now();
|
|
30
|
+
o && h - o > i && d();
|
|
31
|
+
let T = E?.[0] ?? "";
|
|
32
|
+
e += T;
|
|
33
|
+
let k = a;
|
|
34
|
+
const { context_length: S, output: w } = K(
|
|
35
|
+
e,
|
|
36
36
|
"Normal",
|
|
37
37
|
s,
|
|
38
|
-
_,
|
|
39
|
-
f,
|
|
40
38
|
p,
|
|
41
|
-
|
|
39
|
+
m,
|
|
40
|
+
f,
|
|
41
|
+
u,
|
|
42
42
|
{
|
|
43
43
|
typing_mode: !0,
|
|
44
|
-
useNativeNumerals:
|
|
45
|
-
includeInherentVowel:
|
|
44
|
+
useNativeNumerals: c,
|
|
45
|
+
includeInherentVowel: l
|
|
46
46
|
}
|
|
47
47
|
);
|
|
48
|
-
|
|
49
|
-
let
|
|
50
|
-
for (;
|
|
51
|
-
|
|
52
|
-
let
|
|
48
|
+
S > 0 ? a = w : S === 0 && d();
|
|
49
|
+
let g = 0;
|
|
50
|
+
for (; g < w.length && g < k.length && w[g] === k[g]; )
|
|
51
|
+
g++;
|
|
52
|
+
let N = w.substring(g), A = k.length - g;
|
|
53
53
|
return o = Date.now(), {
|
|
54
54
|
/** These number of characters need to be deleted from the current "app" input state */
|
|
55
55
|
to_delete_chars_count: A,
|
|
56
56
|
/** These characters need to be added to the current "app" input state */
|
|
57
|
-
diff_add_text:
|
|
57
|
+
diff_add_text: N
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
return {
|
|
61
61
|
/** Await once, then use `takeKeyInputSync` for best typing latency. */
|
|
62
|
-
ready:
|
|
63
|
-
clearContext:
|
|
64
|
-
takeKeyInput:
|
|
65
|
-
updateUseNativeNumerals: (
|
|
66
|
-
|
|
62
|
+
ready: _,
|
|
63
|
+
clearContext: d,
|
|
64
|
+
takeKeyInput: y,
|
|
65
|
+
updateUseNativeNumerals: (E) => {
|
|
66
|
+
c = E ?? D;
|
|
67
67
|
},
|
|
68
|
-
updateIncludeInherentVowel: (
|
|
69
|
-
|
|
68
|
+
updateIncludeInherentVowel: (E) => {
|
|
69
|
+
l = E ?? I;
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
async function
|
|
74
|
-
if (!(
|
|
73
|
+
async function C(r, n, t, c) {
|
|
74
|
+
if (!(c ?? !0)) {
|
|
75
75
|
t?.(n?.currentTarget?.value);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
const s = n?.nativeEvent ?? n,
|
|
79
|
-
if (!s || !
|
|
78
|
+
const s = n?.nativeEvent ?? n, e = "nativeEvent" in n, a = n?.currentTarget ?? s?.target;
|
|
79
|
+
if (!s || !a || s.isComposing) return;
|
|
80
80
|
if (s.inputType !== "insertText") {
|
|
81
|
-
t?.(
|
|
81
|
+
t?.(a.value), r.clearContext();
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
85
|
-
if (typeof
|
|
86
|
-
t?.(
|
|
84
|
+
const i = s.data;
|
|
85
|
+
if (typeof i != "string" || i.length !== 1) {
|
|
86
|
+
t?.(a.value), r.clearContext();
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const o =
|
|
90
|
-
if (o !==
|
|
91
|
-
t?.(
|
|
89
|
+
const o = a.selectionStart ?? 0, p = a.selectionEnd ?? o;
|
|
90
|
+
if (o !== p) {
|
|
91
|
+
t?.(a.value), r.clearContext();
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
const { diff_add_text:
|
|
96
|
-
|
|
94
|
+
e && t && t(n.currentTarget.value), await r.ready;
|
|
95
|
+
const { diff_add_text: m, to_delete_chars_count: f } = r.takeKeyInput(i), u = o, _ = Math.max(0, u - f - i.length);
|
|
96
|
+
a.setRangeText(m, _, u, "end"), t?.(a.value);
|
|
97
97
|
}
|
|
98
|
-
async function O(r, n, t,
|
|
99
|
-
if (!(
|
|
98
|
+
async function O(r, n, t, c) {
|
|
99
|
+
if (!(c ?? !0))
|
|
100
100
|
return;
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
101
|
+
const e = "nativeEvent" in n ? n.nativeEvent : n, a = n?.currentTarget ?? e?.target;
|
|
102
|
+
if (!e || !a || e.isComposing || (!e.inputType || e.inputType !== "insertText") && (!e.type || e.type !== "textInput"))
|
|
103
103
|
return;
|
|
104
|
-
const
|
|
105
|
-
if (typeof
|
|
106
|
-
if (
|
|
104
|
+
const i = e.data;
|
|
105
|
+
if (typeof i != "string" || i.length === 0) return;
|
|
106
|
+
if (i.length !== 1) {
|
|
107
107
|
r.clearContext();
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
const o =
|
|
111
|
-
if (o !==
|
|
110
|
+
const o = a.selectionStart ?? 0, p = a.selectionEnd ?? o;
|
|
111
|
+
if (o !== p) {
|
|
112
112
|
r.clearContext();
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
const { diff_add_text:
|
|
117
|
-
|
|
115
|
+
e.preventDefault?.(), await r.ready;
|
|
116
|
+
const { diff_add_text: m, to_delete_chars_count: f } = r.takeKeyInput(i), u = o, _ = Math.max(0, u - f);
|
|
117
|
+
a.setRangeText(m, _, u, "end"), t?.(a.value);
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const M = /* @__PURE__ */ new Set([
|
|
120
120
|
"Backspace",
|
|
121
121
|
"Delete",
|
|
122
122
|
"Enter",
|
|
@@ -131,23 +131,80 @@ const k = /* @__PURE__ */ new Set([
|
|
|
131
131
|
"PageUp",
|
|
132
132
|
"PageDown"
|
|
133
133
|
]);
|
|
134
|
-
function
|
|
134
|
+
function $(r, n) {
|
|
135
135
|
const t = r?.nativeEvent ?? r;
|
|
136
136
|
if (t instanceof KeyboardEvent) {
|
|
137
137
|
if (t.isComposing) return !1;
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
140
|
-
if (
|
|
138
|
+
const c = t.key;
|
|
139
|
+
if (!c || c === "Unidentified" || c === "Process" || c === "Dead" || t.ctrlKey || t.metaKey || t.altKey) return !1;
|
|
140
|
+
if (M.has(c))
|
|
141
141
|
return n.clearContext(), !0;
|
|
142
142
|
}
|
|
143
143
|
return !1;
|
|
144
144
|
}
|
|
145
|
+
async function z(r) {
|
|
146
|
+
const n = v(r);
|
|
147
|
+
if (!n || n === "Normal")
|
|
148
|
+
throw new Error(`Invalid script name: ${r}`);
|
|
149
|
+
const t = await x(n);
|
|
150
|
+
return t.krama_text_arr.map((l) => [
|
|
151
|
+
l[0],
|
|
152
|
+
t.list[l[1] ?? -1]?.type ?? "anya"
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
async function P(r) {
|
|
156
|
+
const n = v(r);
|
|
157
|
+
if (!n || n === "Normal")
|
|
158
|
+
throw new Error(`Invalid script name: ${r}`);
|
|
159
|
+
const t = await x(n), c = (s) => {
|
|
160
|
+
const e = /* @__PURE__ */ new Map(), a = [], i = [];
|
|
161
|
+
for (const [o, p, m] of s) {
|
|
162
|
+
const f = `${o}\0${p}`, u = e.get(f);
|
|
163
|
+
if (u === void 0) {
|
|
164
|
+
const _ = [], d = /* @__PURE__ */ new Set();
|
|
165
|
+
for (const y of m)
|
|
166
|
+
d.has(y) || (d.add(y), _.push(y));
|
|
167
|
+
i.push([o, p, _]), e.set(f, i.length - 1), a.push(d);
|
|
168
|
+
} else {
|
|
169
|
+
const _ = a[u], d = i[u][2];
|
|
170
|
+
for (const y of m)
|
|
171
|
+
_.has(y) || (_.add(y), d.push(y));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return i.filter(([, , o]) => o.length > 0);
|
|
175
|
+
}, l = {
|
|
176
|
+
common_krama_map: t.krama_text_arr.map((s) => [
|
|
177
|
+
s[0],
|
|
178
|
+
t.list[s[1] ?? -1]?.type ?? "anya",
|
|
179
|
+
[]
|
|
180
|
+
]),
|
|
181
|
+
script_specific_krama_map: t.custom_script_chars_arr.map((s) => [
|
|
182
|
+
s[0],
|
|
183
|
+
t.list[s[1] ?? -1]?.type ?? "anya",
|
|
184
|
+
[]
|
|
185
|
+
])
|
|
186
|
+
};
|
|
187
|
+
for (let s = 0; s < t.typing_text_to_krama_map.length; s++) {
|
|
188
|
+
const e = t.typing_text_to_krama_map[s], a = e[0];
|
|
189
|
+
if (a !== "") {
|
|
190
|
+
if (e[1] && e[1].custom_back_ref)
|
|
191
|
+
l.script_specific_krama_map[e[1].custom_back_ref][2].push(a);
|
|
192
|
+
else if (e[1] && e[1].krama && e[1].krama.length === 1) {
|
|
193
|
+
const i = e[1].krama[0] ?? -1;
|
|
194
|
+
i !== -1 && l.common_krama_map[i][2].push(a);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return l.common_krama_map = c(l.common_krama_map), l.script_specific_krama_map = c(l.script_specific_krama_map), l;
|
|
199
|
+
}
|
|
145
200
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
201
|
+
U as DEFAULT_AUTO_CONTEXT_CLEAR_TIME_MS,
|
|
202
|
+
I as DEFAULT_INCLUDE_INHERENT_VOWEL,
|
|
148
203
|
D as DEFAULT_USE_NATIVE_NUMERALS,
|
|
149
|
-
|
|
150
|
-
|
|
204
|
+
$ as clearTypingContextOnKeyDown,
|
|
205
|
+
L as createTypingContext,
|
|
206
|
+
z as getScriptKramaData,
|
|
207
|
+
P as getScriptTypingDataMap,
|
|
151
208
|
O as handleTypingBeforeInputEvent,
|
|
152
|
-
|
|
209
|
+
C as handleTypingInputEvent
|
|
153
210
|
};
|
package/dist/lipilekhika.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(O,
|
|
2
|
-
`,"\r"," ",",","~","!","@","?","%"],Re=3;function L(t,e,r){const{from_script_name:n,to_script_name:a,from_script_data:o,to_script_data:i,trans_options:s,result:u,prev_context:_,BRAHMIC_HALANT:c,BRAHMIC_NUQTA:l,typing_mode:p,include_inherent_vowel:h}=t,{next:m,last_extra_call:A}=r??{};let $=!1;if((l&&_.typeAt(-3)==="vyanjana"&&_.textAt(-2)===l&&_.typeAt(-1)==="mAtrA"||_.typeAt(-2)==="vyanjana"&&_.typeAt(-1)==="mAtrA")&&(!e||e[1]?.type==="anya")&&_.clear(),o.script_type==="brahmic"&&i.script_type==="other")e[0]!==c&&(!(D(n)&&e[0]&&e[0].length>0)||e[0].charAt(0)!==c)&&(!l||e[0]!==l)&&(_.typeAt(-1)==="vyanjana"||l&&_.typeAt(-2)==="vyanjana"&&_.textAt(-1)===l)&&(e[1]?.type!=="mAtrA"&&e[0]!==c||e[1]?.type==="anya"||e[1]===null||e[1]===void 0)&&u.emit(i.schwa_character);else if(o.script_type==="other"&&i.script_type==="brahmic")if(_.typeAt(-1)==="vyanjana"&&(e[1]?.type==="mAtrA"||e[1]?.type==="svara")){const y=e[1].type==="svara"?z(i,e[1].mAtrA_krama_ref?.[0]??-1):e[0];D(a)&&N(u.lastChar())?H(u,[y],i.halant,!0):H(u,[y],i.halant,!1),$=!0}else!h&&_.typeAt(-1)==="vyanjana"&&!(e[0]===c||e[1]?.type==="mAtrA")?D(a)&&N(u.lastChar())?H(u,[c],i.halant,!0):(H(u,[c],i.halant,!1),a==="Sinhala"&&s["all_to_sinhala:use_conjunct_enabling_halant"]&&u.rewriteAt(-1,u.lastPiece()+"")):h&&e&&e[1]?.type==="vyanjana"&&(_.typeAt(-1)==="vyanjana"||l&&_.typeAt(-2)==="vyanjana"&&_.textAt(-1)===l)&&(D(a)&&N(u.lastChar())?H(u,[c],i.halant,!0):(H(u,[c],i.halant,!1),a==="Sinhala"&&s["all_to_sinhala:use_conjunct_enabling_halant"]&&u.rewriteAt(-1,u.lastPiece()+"")));let x=!1;return p&&(m===void 0||m.length===0)&&!A&&!(D(a)&&N(u.lastChar()))&&(x=!0,e[1]?.type==="vyanjana"&&(x=!1),x&&_.clear()),(!p||!A&&!x)&&_.push(e),$}function ve(t,e,r){const{custom_rules:n,cursor:a,result:o,from_script_data:i,to_script_data:s}=t,u=e+r;for(let _=0;_<n.length;_++){if(n[_].use_replace===!0)continue;const c=n[_];if(c.type==="replace_prev_krama_keys"){if(c.check_in==="input"){const l=se(a.peekAt,u,c.prev,i),p=a.peekAt(e);if(l.matched&&p!==null){const h=p.ch,m=re(i,h);if(m!==-1&&c.following.indexOf(m)!==-1){const A=oe(c.replace_with,s);o.rewriteTailPieces(l.matchedLen,A)}}}else if(c.check_in==="output"){const l=o.lastPiece();if(!l)continue;const p=re(s,l);if(p!==-1&&c.following.indexOf(p)!==-1){const h=se(o.peekAt,-2,c.prev,s);if(h.matched){const m=oe(c.replace_with,s);o.rewriteTailPieces(h.matchedLen+1,[...m,l])}}}}else if(c.type==="direct_replace"){const l=c.check_in==="output"?s:i;for(const p of c.to_replace){const h=se(o.peekAt,-1,p,l);if(!h.matched)continue;if(c.replace_text){o.rewriteTailPieces(h.matchedLen,[c.replace_text]);break}const m=oe(c.replace_with,l);o.rewriteTailPieces(h.matchedLen,m);break}}}}const ge=(t,e,r)=>{if(!r)return{};const n={};for(const[a,o]of Object.entries(r??{})){if(!(a in te))continue;const i=te[a];(i.from_script_type==="all"&&i.to_script_type==="all"||(i.from_script_type!==void 0&&(i.from_script_type==="all"||i.from_script_type===t.script_type)||i.from_script_name!==void 0&&i.from_script_name.includes(t.script_name))&&(i.to_script_type!==void 0&&(i.to_script_type==="all"||i.to_script_type===e.script_type)||i.to_script_name!==void 0&&i.to_script_name.includes(e.script_name)))&&(n[a]=o)}return n},Ae=(t,e,r)=>{const n=ge(t,e,r),a=Object.keys(n).flatMap(o=>n[o]===!0?te[o].rules:[]);return{trans_options:n,custom_rules:a}},xe=(t,e)=>t.replace_with.map(r=>z(e,r)).join(""),we=(t,e,r,n)=>{if(r.length===0)return t;for(const a of r)if(!(a.use_replace!==!0||a.check_in!==n)){if(a.type==="replace_prev_krama_keys"){const o=a.prev.map(i=>z(e,i)).join("");for(let i of a.following){const s=z(e,i);if(!s)continue;const u=xe(a,e)+s;t=t.replaceAll(o+s,u)}}else if(a.type==="direct_replace"){const o=a.to_replace.map(i=>i.map(s=>z(e,s)).join(""));for(let i of o)t=t.replaceAll(i,xe(a,e))}}return t},Me=!0,Ue=!1,Te=(t,e,r,n,a,o,i,s)=>{const u=s?.useNativeNumerals??Me,_=s?.typing_mode??!1,c=s?.includeInherentVowel??Ue;if(_&&e!=="Normal")throw new Error("Typing mode is only supported with Normal script as the input");_&&(o["normal_to_all:use_typing_chars"]=!0),_&&e==="Normal"&&(t=je(t,r)),t=we(t,n,i,"input");const l=Ne();let p=0;const h=Ie(t),m=Le(Re),A=n.script_type==="brahmic"&&a.script_type==="other"||n.script_type==="other"&&a.script_type==="brahmic"||_&&e==="Normal"&&a.script_type==="other",$=n.script_type==="brahmic"&&a.script_type==="other"?n.nuqta??null:n.script_type==="other"&&a.script_type==="brahmic"?a.nuqta??null:null,x=n.script_type==="brahmic"&&a.script_type==="other"?n.halant:n.script_type==="other"&&a.script_type==="brahmic"?a.halant:null,y={from_script_name:e,to_script_name:r,from_script_data:n,to_script_data:a,trans_options:o,custom_rules:i,cursor:h,result:l,prev_context:m,BRAHMIC_NUQTA:$,BRAHMIC_HALANT:x,typing_mode:_,include_inherent_vowel:c},V=(o["normal_to_all:use_typing_chars"]||_)&&e==="Normal"?a.typing_text_to_krama_map:n.text_to_krama_map;let k=-1;for(;h.pos<t.length;){p=h.pos;const F=h.peek();if(!F)break;const w=F.ch,U=F.width,ie=U===2?1:U;if(k!==-1&&p>=k){k=-1,h.advance(U);continue}if(Pe.indexOf(w)!==-1){h.advance(U),A&&(L(y,[" ",null]),m.clear()),l.emit(w);continue}if(w.match(/^\d$/)&&!u){l.emit(w),h.advance(U),L(y,[w,null]);continue}if(o["all_to_normal:preserve_specific_chars"]&&r==="Normal"){const T=ee(n.custom_script_chars_arr,w,{accessor:(E,I)=>E[I][0]});if(T!==-1){const E=n.custom_script_chars_arr[T];L(y,[E[0],n.list[E[1]??-1]??null]);const I=n.typing_text_to_krama_map[E[2]??-1]?.[0];l.emit(I??""),h.advance(E[0].length);continue}}let X=-1;{let T=0,E=-1;const I=A&&n.script_type==="other"&&a.script_type==="brahmic"&&(m.typeAt(-1)==="vyanjana"||$&&m.typeAt(-2)==="vyanjana"&&m.textAt(-1)===$);for(;;){const W=h.peekAt(p+ie+T),le=W?.ch??"";k!==-1&&le&&N(le)&&(T+=W?.width??0);const S=p+ie+T,d=k!==-1?h.slice(p,k)+(S>k?h.slice(k+1,S):""):h.slice(p,S),C=ee(V,d,{accessor:(b,j)=>b[j][0]});if(C===-1){X=-1;break}const v=V[C];if(I&&v[1].krama&&v[1].krama.length>=1){const b=v[1].krama,j=b[0],P=a.krama_text_arr[j]?.[1],ye=a.list[P??-1]?.type;if(b.length===1&&P!==null&&P!==void 0&&(ye==="svara"||ye==="mAtrA"))E=C;else if(E!==-1){X=E;break}}if(v[1].next&&v[1].next.length>0){const b=h.peekAt(S),j=b?.ch;if(D(e)&&n.script_type==="brahmic"){const Z=b?h.peekAt(S+b.width):null,P=Z?.ch,B=(b&&Z?h.peekAt(S+b.width+Z.width):null)?.ch;if(k===-1&&P!==void 0&&N(P)&&v[1].next.indexOf(P)!==-1){const Y=ee(n.text_to_krama_map,d+P,{accessor:(R,g)=>R[g][0]}),G=M(n.krama_text_arr,n.krama_text_arr_index,j??"",{accessor:(R,g)=>R[g][0]});if(Y!==-1&&G!==-1){X=Y;const R=n.krama_text_arr[G],g=n.list[R[1]??-1]?.type;if(j===n.halant||g==="mAtrA"){k=S+(b?.width??0);break}}}else if(k===-1&&B!==void 0&&N(B)&&v[1].next.indexOf(B)!==-1){const Y=ee(n.text_to_krama_map,d+B,{accessor:(g,K)=>g[K][0]}),G=M(n.krama_text_arr,n.krama_text_arr_index,j??"",{accessor:(g,K)=>g[K][0]}),R=M(n.krama_text_arr,n.krama_text_arr_index,P??"",{accessor:(g,K)=>g[K][0]});if(Y!==-1&&G!==-1&&R!==-1){const g=n.krama_text_arr[G],K=n.krama_text_arr[R];X=Y;const de=n.list[g[1]??-1]?.type,tt=n.list[K[1]??-1]?.type;if(de==="mAtrA"&&tt==="mAtrA"){k=S+(b?.width??0)+(Z?.width??0);break}}}if(k===-1&&j!==void 0&&P!==void 0&&_e(P)&&B!==void 0&&N(B)&&v[1].next.indexOf(B)!==-1){const Y=M(n.krama_text_arr,n.krama_text_arr_index,j??"",{accessor:(G,R)=>G[R][0]});if(Y!==-1){const G=n.krama_text_arr[Y];if(n.list[G[1]??-1]?.type==="mAtrA"){const g=ee(n.text_to_krama_map,d+B,{accessor:(K,de)=>K[de][0]});if(g!==-1){X=g,k=S+(b?.width??0)+(Z?.width??0);break}}}}}if(j!==void 0&&v[1].next.indexOf(j)!==-1){T+=b?.width??0;continue}}X=C;break}}const f=X!==-1?V[X]:null;if(f!==null){const T=k!==-1&&f[0].length>1&&n.list[n.krama_text_arr[f[1].krama?.[0]??-1]?.[1]??-1]?.type==="vyanjana"&&N(f[0].at(-1)??void 0)?1:0,E=f[0].length-T;if(h.advance(E),p=h.pos,o["normal_to_all:use_typing_chars"]&&"custom_back_ref"in f[1]&&f[1].custom_back_ref!==void 0&&f[1].custom_back_ref!==null){const I=a.custom_script_chars_arr[f[1].custom_back_ref]??null;te!==null&&(l.emit(I[0]),L(y,[f[0],a.list[I[1]??-1]??null],{next:f[1].next??void 0}));continue}if(f[1].krama!==null&&f[1].krama!==void 0&&f[1].krama.some(I=>I!==-1)){const W=f[1].krama.map(d=>z(a,d)),le=W.join("");let S=!1;if(A)if(n.script_type==="brahmic"&&a.script_type==="other"){let d=null;if(!o["normal_to_all:use_typing_chars"]&&f[1].fallback_list_ref!==void 0&&f[1].fallback_list_ref!==null)d=n.list[f[1].fallback_list_ref];else if(!f[1].krama||f[1].krama.length===0)d=null;else{const C=f[1].krama.map(v=>n.list[n.krama_text_arr[v][1]??-1]);D(e)&&C.some(v=>v?.type==="mAtrA")&&C.some(v=>v?.type==="vyanjana")?d={...C[0],type:"anya"}:D(e)&&C.length>1&&C.some(v=>v==null)?d=C.at(-1):d=C[0]}S=L(y,[f[0],d])}else if(a.script_type==="brahmic"&&n.script_type==="other"){let d=null;f[1].fallback_list_ref!==void 0&&f[1].fallback_list_ref!==null?d=a.list[f[1].fallback_list_ref]:d=f[1].krama&&f[1].krama.length>0?a.list[a.krama_text_arr[f[1].krama[0]]?.[1]??-1]??null:null,_&&e==="Normal"?S=L(y,[f[0],d],{next:f[1].next??void 0}):S=L(y,[f[0],d])}else _&&e==="Normal"&&a.script_type==="other"&&(S=L(y,[f[0],null],{next:f[1].next??void 0}));if(!S)if(a.script_type==="brahmic"&&D(r)&&(a.list[f[1].krama?.at(-1)??-1]?.type==="mAtrA"||le===a.halant)&&N(l.lastChar()))H(l,W,a.halant,!0);else if(D(r)&&_e(W.at(-1)?.at(-1)??"")&&N(l.lastChar())){const d=l.popLastChar();l.emitPieces(W),l.emit(d??"")}else l.emitPieces(W);ve(y,p,-E);continue}else if(f[1].krama!==null&&f[1].krama!==void 0&&f[1].krama.some(I=>I===-1)){l.emit(f[0]),_&&L(y,[f[0],null],{next:f[1].next??void 0});continue}}else h.advance(U),p=h.pos;const ne=f===null?w:f[0],ae=re(n,ne);if(ae===-1){A&&(L(y,[ne,null]),m.clear()),l.emit(ne);continue}let me=!1;if(A&&(n.script_type==="brahmic"?me=L(y,[ne,n.list[n.krama_text_arr[ae][1]??-1]]):a.script_type==="brahmic"&&(me=L(y,[ne,a.list[a.krama_text_arr[ae][1]??-1]]))),!me){const T=z(a,ae);if(a.script_type==="brahmic"&&D(r)&&(a.list[a.krama_text_arr[ae][1]??-1]?.type==="mAtrA"||T===a.halant)&&N(l.lastChar()))H(l,[T],a.halant,!0);else if(D(r)&&_e(T)&&N(l.lastChar())){const E=l.popLastChar();l.emit(T),l.emit(E??"")}else l.emit(T)}ve(y,p,-U)}A&&L(y,[void 0,null],{last_extra_call:!0});let J=l.toString();return J=we(J,a,i,"output"),{output:J,context_length:m.length()}},Be=async(t,e,r,n,a)=>{const[o,i]=await Promise.all([q(e),q(r)]),{trans_options:s,custom_rules:u}=Ae(o,i,n);return Te(t,e,r,o,i,s,u,a)},Ge={script_list:{Devanagari:1,Telugu:2,Tamil:3,"Tamil-Extended":4,Bengali:5,Kannada:6,Gujarati:7,Malayalam:8,Odia:9,Sinhala:10,Normal:11,Romanized:12,Gurumukhi:13,Assamese:14,"Purna-Devanagari":15,Brahmi:16,Granth:17,Modi:18,Sharada:20,Siddham:21},lang_list:{English:1,Sanskrit:2,Hindi:3,Telugu:4,Tamil:5,Bengali:6,Kannada:7,Gujarati:8,Malayalam:9,Odia:10,Sinhala:11,Marathi:12,Nepali:13,Punjabi:14,Assamese:15}},{script_list:Ke,lang_list:ze}=Ge,ue=Object.keys(Ke),pe=Object.keys(ze),He=Array.from(new Set([...pe,...ue])),$e={Bengali:"Bengali",Gujarati:"Gujarati",Hindi:"Devanagari",Kannada:"Kannada",Malayalam:"Malayalam",Odia:"Odia",Sinhala:"Sinhala",Tamil:"Tamil",Telugu:"Telugu",English:"Normal",Sanskrit:"Devanagari",Marathi:"Devanagari",Nepali:"Devanagari",Punjabi:"Gurumukhi",Assamese:"Assamese"},Ee={dev:"Devanagari",te:"Telugu",tel:"Telugu",tam:"Tamil","tam-ex":"Tamil-Extended",ben:"Bengali",be:"Bengali",ka:"Kannada",kan:"Kannada",gu:"Gujarati",guj:"Gujarati",mal:"Malayalam",or:"Odia",od:"Odia",oriya:"Odia",si:"Sinhala",sinh:"Sinhala",sin:"Sinhala",en:"Normal",eng:"Normal",la:"Normal",lat:"Normal",nor:"Normal",norm:"Normal",rom:"Romanized",gur:"Gurumukhi",as:"Assamese",sa:"Devanagari",san:"Devanagari",hin:"Devanagari",hi:"Devanagari",mar:"Devanagari",ne:"Devanagari",nep:"Devanagari",pun:"Gurumukhi"};function Ve(t){return t.toLowerCase().replace(/(^|-)([a-z])/g,(e,r,n)=>r+n.toUpperCase())}const Q=t=>{const e=Ve(t);return ue.includes(e)?e:pe.includes(e)?$e[e]:t.toLocaleLowerCase()in Ee?Ee[t.toLocaleLowerCase()]:null},Fe=async t=>{const e=Q(t);if(!e)throw new Error(`Invalid script name: ${t}`);return await q(e)};async function Xe(t,e,r,n){const a=Q(e);if(!a)throw new Error(`Invalid script name: ${e}`);const o=Q(r);if(!o)throw new Error(`Invalid script name: ${r}`);return a===o?t:(await Be(t,a,o,n)).output}async function We(t,e){const r=Q(t);if(!r)throw new Error(`Invalid script name: ${t}`);const n=Q(e);if(!n)throw new Error(`Invalid script name: ${e}`);const a=await q(r),o=await q(n);return Object.keys(ge(a,o,Object.fromEntries(Object.keys(te).map(i=>[i,!0]))))}const Se=4500,he=!0,fe=!1;function Ye(t,e){const{autoContextTClearTimeMs:r}=e??{};let n=e?.useNativeNumerals??he,a=e?.includeInherentVowel??fe;const o=Q(t);if(!o)throw new Error(`Invalid script name: ${t}`);let i="",s="";const u=r??Se;let _=null,c=null,l=null,p={},h=[];const m=(async()=>{const[x,y]=await Promise.all([q("Normal"),q(o)]);c=x,l=y;const V=Ae(x,y);p=V.trans_options,h=V.custom_rules})();function A(){_=null,i="",s=""}function $(x){if(!c||!l)throw new Error("Typing context not ready. Await `ctx.ready` before calling takeKeyInputSync.");const y=Date.now();_&&y-_>u&&A();let V=x?.[0]??"";i+=V;let k=s;const{context_length:J,output:F}=Te(i,"Normal",o,c,l,p,h,{typing_mode:!0,useNativeNumerals:n,includeInherentVowel:a});J>0?s=F:J===0&&A();let w=0;for(;w<F.length&&w<k.length&&F[w]===k[w];)w++;let U=F.substring(w),ie=k.length-w;return _=Date.now(),{to_delete_chars_count:ie,diff_add_text:U}}return{ready:m,clearContext:A,takeKeyInput:$,updateUseNativeNumerals:x=>{n=x??he},updateIncludeInherentVowel:x=>{a=x??fe}}}async function qe(t,e,r,n){if(!(n??!0)){r?.(e?.currentTarget?.value);return}const o=e?.nativeEvent??e,i="nativeEvent"in e,s=e?.currentTarget??o?.target;if(!o||!s||o.isComposing)return;if(o.inputType!=="insertText"){r?.(s.value),t.clearContext();return}const u=o.data;if(typeof u!="string"||u.length!==1){r?.(s.value),t.clearContext();return}const _=s.selectionStart??0,c=s.selectionEnd??_;if(_!==c){r?.(s.value),t.clearContext();return}i&&r&&r(e.currentTarget.value),await t.ready;const{diff_add_text:l,to_delete_chars_count:p}=t.takeKeyInput(u),h=_,m=Math.max(0,h-p-u.length);s.setRangeText(l,m,h,"end"),r?.(s.value)}async function Qe(t,e,r,n){if(!(n??!0))return;const i="nativeEvent"in e?e.nativeEvent:e,s=e?.currentTarget??i?.target;if(!i||!s||i.isComposing||(!i.inputType||i.inputType!=="insertText")&&(!i.type||i.type!=="textInput"))return;const u=i.data;if(typeof u!="string"||u.length===0)return;if(u.length!==1){t.clearContext();return}const _=s.selectionStart??0,c=s.selectionEnd??_;if(_!==c){t.clearContext();return}i.preventDefault?.(),await t.ready;const{diff_add_text:l,to_delete_chars_count:p}=t.takeKeyInput(u),h=_,m=Math.max(0,h-p);s.setRangeText(l,m,h,"end"),r?.(s.value)}const Je=new Set(["Backspace","Delete","Enter","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Ze(t,e){const r=t?.nativeEvent??t;if(r instanceof KeyboardEvent){if(r.isComposing)return!1;const n=r.key;if(!n||n==="Unidentified"||n==="Process"||n==="Dead"||r.ctrlKey||r.metaKey||r.altKey)return!1;if(Je.has(n))return e.clearContext(),!0}return!1}const et=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_AUTO_CONTEXT_CLEAR_TIME_MS:Se,DEFAULT_INCLUDE_INHERENT_VOWEL:fe,DEFAULT_USE_NATIVE_NUMERALS:he,clearTypingContextOnKeyDown:Ze,createTypingContext:Ye,handleTypingBeforeInputEvent:Qe,handleTypingInputEvent:qe},Symbol.toStringTag,{value:"Module"}));O.ALL_LANG_SCRIPT_LIST=He,O.LANG_LIST=pe,O.SCRIPT_LIST=ue,O.getAllOptions=We,O.preloadScriptData=Fe,O.transliterate=Xe,O.typing=et,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(O,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(O=typeof globalThis<"u"?globalThis:O||self,U(O.lipilekhika={}))})(this,(function(O){"use strict";function U(t,e,r,n){const{accessor:a,compareFn:l}=n??{},i=a??((s,c)=>s[c]);let o=0,u=e.length-1,_=-1;for(;o<=u;){const s=Math.floor((o+u)/2),c=e[s],p=i(t,c);let h;l?h=l(r,p):h=r<p?-1:r>p?1:0,h===0?(_=c,u=s-1):h<0?u=s-1:o=s+1}return _}function ee(t,e,r){const{accessor:n,compareFn:a}=r??{},l=n??((_,s)=>_[s]);let i=0,o=t.length-1,u=-1;for(;i<=o;){const _=Math.floor((i+o)/2),s=l(t,_);let c;a?c=a(e,s):c=e<s?-1:e>s?1:0,c===0?(u=_,o=_-1):c<0?o=_-1:i=_+1}return u}const ce={},K=async t=>{{if(ce[t])return ce[t];const r=`https://cdn.jsdelivr.net/npm/lipilekhika@1.0.0/dist/umd_json/script_data/${t}.json`,a=(await fetch(r)).json();return ce[t]=a,a}},te={"all_to_normal:replace_pancham_varga_varna_with_n":{from_script_type:"all",to_script_name:["Normal"],check_in:"output",rules:[{type:"replace_prev_krama_keys",check_in:"output",prev:[60],following:[52,53,54,55,56,57,58,59],replace_with:[72]},{type:"replace_prev_krama_keys",check_in:"output",prev:[67],following:[61,62,63,64,65,66],replace_with:[72]}]},"brahmic_to_brahmic:replace_pancham_varga_varna_with_anusvAra":{from_script_type:"brahmic",to_script_type:"brahmic",check_in:"input",rules:[{type:"replace_prev_krama_keys",check_in:"input",prev:[60,49],following:[52,53,54,55,56,57,58,59],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[67,49],following:[61,62,63,64,65,66],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[81,49],following:[74,75,76,77,78,79,80],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[72,49],following:[68,69,70,71],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[88,49],following:[82,83,85,86,87],replace_with:[45]}]},"all_to_sinhala:use_conjunct_enabling_halant":{from_script_type:"all",to_script_name:["Sinhala"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[49]],replace_text:"්",replace_with:[]}]},"all_to_normal:remove_virAma_and_double_virAma":{from_script_type:"all",to_script_name:["Normal","Romanized"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[116],[115]],replace_with:[-1]}]},"all_to_normal:replace_avagraha_with_a":{from_script_type:"all",to_script_name:["Normal","Romanized"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[48]],replace_with:[1]}]},"normal_to_all:use_typing_chars":{from_script_name:["Normal"],to_script_type:"all",check_in:"output",rules:[]},"all_to_normal:preserve_specific_chars":{from_script_type:"all",to_script_name:["Normal"],check_in:"output",rules:[]}},be=(t,e)=>{const r=t.krama_text_arr[e]?.[0];return typeof r=="string"?r:null},H=(t,e)=>be(t,e)??"",re=(t,e)=>U(t.krama_text_arr,t.krama_text_arr_index,e,{accessor:(r,n)=>r[n][0]}),Ne=()=>{let t=[];function e(s){s&&t.push(s)}function r(s){for(const c of s)e(c)}function n(){return t.at(-1)}function a(){return n()?.at(-1)}function l(){const s=n();if(!s)return;const c=s.at(-1),p=s.slice(0,-1);return p?t[t.length-1]=p:t.pop(),c}function i(s,c){t.splice(-s,s,...c.filter(Boolean))}function o(s,c){const p=l();if(!p){r(s),r(c);return}r(s),e(p),r(c)}function u(s){const c=t.at(s);return c?{cp:s,ch:c,width:c.length}:null}function _(s,c){s<0&&(s=t.length+s),!(s<0||s>=t.length)&&(t[s]=c)}return{emit:e,emitPieces:r,lastPiece:n,lastChar:a,popLastChar:l,rewriteTailPieces:i,withLastCharMovedAfter:o,toString:()=>t.join(""),rewriteAt:_,peekAt:u}},Ie=t=>{let e=[];function r(){e=[]}function n(){return e.length}function a(p){return e.at(p)}function l(){return e.at(-1)}function i(){return l()?.[0]}function o(){return l()?.[1]?.type}function u(p){return a(p)?.[1]?.type}function _(p){return a(p)?.[0]}function s(p){return o()===p}function c(p){const h=p[0];h!==void 0&&h.length>0&&e.push(p),e.length>t&&e.shift()}return{clear:r,length:n,at:a,last:l,lastText:i,lastType:o,typeAt:u,textAt:_,isLastType:s,push:c}},Le=t=>{let e=0;function r(o){const u=t.codePointAt(o);if(u===void 0)return null;const _=String.fromCodePoint(u);return{cp:u,ch:_,width:_.length}}function n(){return r(e)}function a(o){return r(e+o)}function l(o){e+=o}function i(o,u){return t.substring(o,u)}return{get pos(){return e},peek:n,peekAt:r,peekAtOffsetUnits:a,advance:l,slice:i}},se=(t,e,r,n)=>{for(let a=0;a<r.length;a++){const l=r[r.length-1-a],i=t(e-a);if(i===null)return{matched:!1,matchedLen:0};const o=re(n,i.ch);if(o===-1||o!==l)return{matched:!1,matchedLen:0}}return{matched:!0,matchedLen:r.length}},oe=(t,e)=>t.map(r=>H(e,r)).filter(Boolean),De=["²","³","⁴"],I=t=>!!t&&De.indexOf(t)!==-1,Oe=["॒","॑","᳚","᳛"],_e=t=>!!t&&Oe.indexOf(t)!==-1,C=t=>t==="Tamil-Extended",V=(t,e,r,n)=>{if(e.length===0)return;if(!n){t.emitPieces(e);return}const a=e[0]??"";if(a[0]===r){const l=a.slice(1),i=[];l&&i.push(l);for(let o=1;o<e.length;o++)i.push(e[o]);t.withLastCharMovedAfter([r],i)}else t.withLastCharMovedAfter(e,[])},ke=["#an","#sss","#ss","#s"],Ce=["↓","↑↑↑","↑↑","↑"],je=(t,e)=>{if(!t)return t;if(t.indexOf("x")!==-1&&(t=t.replaceAll("x","kSh")),e==="Tamil-Extended")for(let r=0;r<ke.length;r++){const n=ke[r];t.indexOf(n)!==-1&&(t=t.replaceAll(n,Ce[r]))}return t},Me=[" ",`
|
|
2
|
+
`,"\r"," ",",","~","!","@","?","%"],Pe=3;function L(t,e,r){const{from_script_name:n,to_script_name:a,from_script_data:l,to_script_data:i,trans_options:o,result:u,prev_context:_,BRAHMIC_HALANT:s,BRAHMIC_NUQTA:c,typing_mode:p,include_inherent_vowel:h}=t,{next:f,last_extra_call:d}=r??{};let x=!1;if((c&&_.typeAt(-3)==="vyanjana"&&_.textAt(-2)===c&&_.typeAt(-1)==="mAtrA"||_.typeAt(-2)==="vyanjana"&&_.typeAt(-1)==="mAtrA")&&(!e||e[1]?.type==="anya")&&_.clear(),l.script_type==="brahmic"&&i.script_type==="other")e[0]!==s&&(!(C(n)&&e[0]&&e[0].length>0)||e[0].charAt(0)!==s)&&(!c||e[0]!==c)&&(_.typeAt(-1)==="vyanjana"||c&&_.typeAt(-2)==="vyanjana"&&_.textAt(-1)===c)&&(e[1]?.type!=="mAtrA"&&e[0]!==s||e[1]?.type==="anya"||e[1]===null||e[1]===void 0)&&u.emit(i.schwa_character);else if(l.script_type==="other"&&i.script_type==="brahmic")if(_.typeAt(-1)==="vyanjana"&&(e[1]?.type==="mAtrA"||e[1]?.type==="svara")){const y=e[1].type==="svara"?H(i,e[1].mAtrA_krama_ref?.[0]??-1):e[0];C(a)&&I(u.lastChar())?V(u,[y],i.halant,!0):V(u,[y],i.halant,!1),x=!0}else!h&&_.typeAt(-1)==="vyanjana"&&!(e[0]===s||e[1]?.type==="mAtrA")?C(a)&&I(u.lastChar())?V(u,[s],i.halant,!0):(V(u,[s],i.halant,!1),a==="Sinhala"&&o["all_to_sinhala:use_conjunct_enabling_halant"]&&u.rewriteAt(-1,u.lastPiece()+"")):h&&e&&e[1]?.type==="vyanjana"&&(_.typeAt(-1)==="vyanjana"||c&&_.typeAt(-2)==="vyanjana"&&_.textAt(-1)===c)&&(C(a)&&I(u.lastChar())?V(u,[s],i.halant,!0):(V(u,[s],i.halant,!1),a==="Sinhala"&&o["all_to_sinhala:use_conjunct_enabling_halant"]&&u.rewriteAt(-1,u.lastPiece()+"")));let w=!1;return p&&(f===void 0||f.length===0)&&!d&&!(C(a)&&I(u.lastChar()))&&(w=!0,e[1]?.type==="vyanjana"&&(w=!1),w&&_.clear()),(!p||!d&&!w)&&_.push(e),x}function ge(t,e,r){const{custom_rules:n,cursor:a,result:l,from_script_data:i,to_script_data:o}=t,u=e+r;for(let _=0;_<n.length;_++){if(n[_].use_replace===!0)continue;const s=n[_];if(s.type==="replace_prev_krama_keys"){if(s.check_in==="input"){const c=se(a.peekAt,u,s.prev,i),p=a.peekAt(e);if(c.matched&&p!==null){const h=p.ch,f=re(i,h);if(f!==-1&&s.following.indexOf(f)!==-1){const d=oe(s.replace_with,o);l.rewriteTailPieces(c.matchedLen,d)}}}else if(s.check_in==="output"){const c=l.lastPiece();if(!c)continue;const p=re(o,c);if(p!==-1&&s.following.indexOf(p)!==-1){const h=se(l.peekAt,-2,s.prev,o);if(h.matched){const f=oe(s.replace_with,o);l.rewriteTailPieces(h.matchedLen+1,[...f,c])}}}}else if(s.type==="direct_replace"){const c=s.check_in==="output"?o:i;for(const p of s.to_replace){const h=se(l.peekAt,-1,p,c);if(!h.matched)continue;if(s.replace_text){l.rewriteTailPieces(h.matchedLen,[s.replace_text]);break}const f=oe(s.replace_with,c);l.rewriteTailPieces(h.matchedLen,f);break}}}}const ve=(t,e,r)=>{if(!r)return{};const n={};for(const[a,l]of Object.entries(r??{})){if(!(a in te))continue;const i=te[a];(i.from_script_type==="all"&&i.to_script_type==="all"||(i.from_script_type!==void 0&&(i.from_script_type==="all"||i.from_script_type===t.script_type)||i.from_script_name!==void 0&&i.from_script_name.includes(t.script_name))&&(i.to_script_type!==void 0&&(i.to_script_type==="all"||i.to_script_type===e.script_type)||i.to_script_name!==void 0&&i.to_script_name.includes(e.script_name)))&&(n[a]=l)}return n},xe=(t,e,r)=>{const n=ve(t,e,r),a=Object.keys(n).flatMap(l=>n[l]===!0?te[l].rules:[]);return{trans_options:n,custom_rules:a}},Ae=(t,e)=>t.replace_with.map(r=>H(e,r)).join(""),we=(t,e,r,n)=>{if(r.length===0)return t;for(const a of r)if(!(a.use_replace!==!0||a.check_in!==n)){if(a.type==="replace_prev_krama_keys"){const l=a.prev.map(i=>H(e,i)).join("");for(let i of a.following){const o=H(e,i);if(!o)continue;const u=Ae(a,e)+o;t=t.replaceAll(l+o,u)}}else if(a.type==="direct_replace"){const l=a.to_replace.map(i=>i.map(o=>H(e,o)).join(""));for(let i of l)t=t.replaceAll(i,Ae(a,e))}}return t},Re=!0,Ue=!1,Te=(t,e,r,n,a,l,i,o)=>{const u=o?.useNativeNumerals??Re,_=o?.typing_mode??!1,s=o?.includeInherentVowel??Ue;if(_&&e!=="Normal")throw new Error("Typing mode is only supported with Normal script as the input");_&&(l["normal_to_all:use_typing_chars"]=!0),_&&e==="Normal"&&(t=je(t,r)),t=we(t,n,i,"input");const c=Ne();let p=0;const h=Le(t),f=Ie(Pe),d=n.script_type==="brahmic"&&a.script_type==="other"||n.script_type==="other"&&a.script_type==="brahmic"||_&&e==="Normal"&&a.script_type==="other",x=n.script_type==="brahmic"&&a.script_type==="other"?n.nuqta??null:n.script_type==="other"&&a.script_type==="brahmic"?a.nuqta??null:null,w=n.script_type==="brahmic"&&a.script_type==="other"?n.halant:n.script_type==="other"&&a.script_type==="brahmic"?a.halant:null,y={from_script_name:e,to_script_name:r,from_script_data:n,to_script_data:a,trans_options:l,custom_rules:i,cursor:h,result:c,prev_context:f,BRAHMIC_NUQTA:x,BRAHMIC_HALANT:w,typing_mode:_,include_inherent_vowel:s},X=(l["normal_to_all:use_typing_chars"]||_)&&e==="Normal"?a.typing_text_to_krama_map:n.text_to_krama_map;let g=-1;for(;h.pos<t.length;){p=h.pos;const W=h.peek();if(!W)break;const T=W.ch,z=W.width,ie=z===2?1:z;if(g!==-1&&p>=g){g=-1,h.advance(z);continue}if(Me.indexOf(T)!==-1){h.advance(z),d&&(L(y,[" ",null]),f.clear()),c.emit(T);continue}if(T.match(/^\d$/)&&!u){c.emit(T),h.advance(z),L(y,[T,null]);continue}if(l["all_to_normal:preserve_specific_chars"]&&r==="Normal"){const E=ee(n.custom_script_chars_arr,T,{accessor:(S,D)=>S[D][0]});if(E!==-1){const S=n.custom_script_chars_arr[E];L(y,[S[0],n.list[S[1]??-1]??null]);const D=n.typing_text_to_krama_map[S[2]??-1]?.[0];c.emit(D??""),h.advance(S[0].length);continue}}let q=-1;{let E=0,S=-1;const D=d&&n.script_type==="other"&&a.script_type==="brahmic"&&(f.typeAt(-1)==="vyanjana"||x&&f.typeAt(-2)==="vyanjana"&&f.textAt(-1)===x);for(;;){const Y=h.peekAt(p+ie+E),le=Y?.ch??"";g!==-1&&le&&I(le)&&(E+=Y?.width??0);const b=p+ie+E,k=g!==-1?h.slice(p,g)+(b>g?h.slice(g+1,b):""):h.slice(p,b),j=ee(X,k,{accessor:(N,M)=>N[M][0]});if(j===-1){q=-1;break}const v=X[j];if(D&&v[1].krama&&v[1].krama.length>=1){const N=v[1].krama,M=N[0],P=a.krama_text_arr[M]?.[1],ye=a.list[P??-1]?.type;if(N.length===1&&P!==null&&P!==void 0&&(ye==="svara"||ye==="mAtrA"))S=j;else if(S!==-1){q=S;break}}if(v[1].next&&v[1].next.length>0){const N=h.peekAt(b),M=N?.ch;if(C(e)&&n.script_type==="brahmic"){const Z=N?h.peekAt(b+N.width):null,P=Z?.ch,B=(N&&Z?h.peekAt(b+N.width+Z.width):null)?.ch;if(g===-1&&P!==void 0&&I(P)&&v[1].next.indexOf(P)!==-1){const Q=ee(n.text_to_krama_map,k+P,{accessor:(R,A)=>R[A][0]}),G=U(n.krama_text_arr,n.krama_text_arr_index,M??"",{accessor:(R,A)=>R[A][0]});if(Q!==-1&&G!==-1){q=Q;const R=n.krama_text_arr[G],A=n.list[R[1]??-1]?.type;if(M===n.halant||A==="mAtrA"){g=b+(N?.width??0);break}}}else if(g===-1&&B!==void 0&&I(B)&&v[1].next.indexOf(B)!==-1){const Q=ee(n.text_to_krama_map,k+B,{accessor:(A,$)=>A[$][0]}),G=U(n.krama_text_arr,n.krama_text_arr_index,M??"",{accessor:(A,$)=>A[$][0]}),R=U(n.krama_text_arr,n.krama_text_arr_index,P??"",{accessor:(A,$)=>A[$][0]});if(Q!==-1&&G!==-1&&R!==-1){const A=n.krama_text_arr[G],$=n.krama_text_arr[R];q=Q;const de=n.list[A[1]??-1]?.type,at=n.list[$[1]??-1]?.type;if(de==="mAtrA"&&at==="mAtrA"){g=b+(N?.width??0)+(Z?.width??0);break}}}if(g===-1&&M!==void 0&&P!==void 0&&_e(P)&&B!==void 0&&I(B)&&v[1].next.indexOf(B)!==-1){const Q=U(n.krama_text_arr,n.krama_text_arr_index,M??"",{accessor:(G,R)=>G[R][0]});if(Q!==-1){const G=n.krama_text_arr[Q];if(n.list[G[1]??-1]?.type==="mAtrA"){const A=ee(n.text_to_krama_map,k+B,{accessor:($,de)=>$[de][0]});if(A!==-1){q=A,g=b+(N?.width??0)+(Z?.width??0);break}}}}}if(M!==void 0&&v[1].next.indexOf(M)!==-1){E+=N?.width??0;continue}}q=j;break}}const m=q!==-1?X[q]:null;if(m!==null){const E=g!==-1&&m[0].length>1&&n.list[n.krama_text_arr[m[1].krama?.[0]??-1]?.[1]??-1]?.type==="vyanjana"&&I(m[0].at(-1)??void 0)?1:0,S=m[0].length-E;if(h.advance(S),p=h.pos,l["normal_to_all:use_typing_chars"]&&"custom_back_ref"in m[1]&&m[1].custom_back_ref!==void 0&&m[1].custom_back_ref!==null){const D=a.custom_script_chars_arr[m[1].custom_back_ref]??null;te!==null&&(c.emit(D[0]),L(y,[m[0],a.list[D[1]??-1]??null],{next:m[1].next??void 0}));continue}if(m[1].krama!==null&&m[1].krama!==void 0&&m[1].krama.some(D=>D!==-1)){const Y=m[1].krama.map(k=>H(a,k)),le=Y.join("");let b=!1;if(d)if(n.script_type==="brahmic"&&a.script_type==="other"){let k=null;if(!l["normal_to_all:use_typing_chars"]&&m[1].fallback_list_ref!==void 0&&m[1].fallback_list_ref!==null)k=n.list[m[1].fallback_list_ref];else if(!m[1].krama||m[1].krama.length===0)k=null;else{const j=m[1].krama.map(v=>n.list[n.krama_text_arr[v][1]??-1]);C(e)&&j.some(v=>v?.type==="mAtrA")&&j.some(v=>v?.type==="vyanjana")?k={...j[0],type:"anya"}:C(e)&&j.length>1&&j.some(v=>v==null)?k=j.at(-1):k=j[0]}b=L(y,[m[0],k])}else if(a.script_type==="brahmic"&&n.script_type==="other"){let k=null;m[1].fallback_list_ref!==void 0&&m[1].fallback_list_ref!==null?k=a.list[m[1].fallback_list_ref]:k=m[1].krama&&m[1].krama.length>0?a.list[a.krama_text_arr[m[1].krama[0]]?.[1]??-1]??null:null,_&&e==="Normal"?b=L(y,[m[0],k],{next:m[1].next??void 0}):b=L(y,[m[0],k])}else _&&e==="Normal"&&a.script_type==="other"&&(b=L(y,[m[0],null],{next:m[1].next??void 0}));if(!b)if(a.script_type==="brahmic"&&C(r)&&(a.list[m[1].krama?.at(-1)??-1]?.type==="mAtrA"||le===a.halant)&&I(c.lastChar()))V(c,Y,a.halant,!0);else if(C(r)&&_e(Y.at(-1)?.at(-1)??"")&&I(c.lastChar())){const k=c.popLastChar();c.emitPieces(Y),c.emit(k??"")}else c.emitPieces(Y);ge(y,p,-S);continue}else if(m[1].krama!==null&&m[1].krama!==void 0&&m[1].krama.some(D=>D===-1)){c.emit(m[0]),_&&L(y,[m[0],null],{next:m[1].next??void 0});continue}}else h.advance(z),p=h.pos;const ne=m===null?T:m[0],ae=re(n,ne);if(ae===-1){d&&(L(y,[ne,null]),f.clear()),c.emit(ne);continue}let fe=!1;if(d&&(n.script_type==="brahmic"?fe=L(y,[ne,n.list[n.krama_text_arr[ae][1]??-1]]):a.script_type==="brahmic"&&(fe=L(y,[ne,a.list[a.krama_text_arr[ae][1]??-1]]))),!fe){const E=H(a,ae);if(a.script_type==="brahmic"&&C(r)&&(a.list[a.krama_text_arr[ae][1]??-1]?.type==="mAtrA"||E===a.halant)&&I(c.lastChar()))V(c,[E],a.halant,!0);else if(C(r)&&_e(E)&&I(c.lastChar())){const S=c.popLastChar();c.emit(E),c.emit(S??"")}else c.emit(E)}ge(y,p,-z)}d&&L(y,[void 0,null],{last_extra_call:!0});let J=c.toString();return J=we(J,a,i,"output"),{output:J,context_length:f.length()}},Ke=async(t,e,r,n,a)=>{const[l,i]=await Promise.all([K(e),K(r)]),{trans_options:o,custom_rules:u}=xe(l,i,n);return Te(t,e,r,l,i,o,u,a)},ze={script_list:{Devanagari:1,Telugu:2,Tamil:3,"Tamil-Extended":4,Bengali:5,Kannada:6,Gujarati:7,Malayalam:8,Odia:9,Sinhala:10,Normal:11,Romanized:12,Gurumukhi:13,Assamese:14,"Purna-Devanagari":15,Brahmi:16,Granth:17,Modi:18,Sharada:20,Siddham:21},lang_list:{English:1,Sanskrit:2,Hindi:3,Telugu:4,Tamil:5,Bengali:6,Kannada:7,Gujarati:8,Malayalam:9,Odia:10,Sinhala:11,Marathi:12,Nepali:13,Punjabi:14,Assamese:15}},{script_list:Be,lang_list:Ge}=ze,ue=Object.keys(Be),pe=Object.keys(Ge),$e=Array.from(new Set([...pe,...ue])),He={Bengali:"Bengali",Gujarati:"Gujarati",Hindi:"Devanagari",Kannada:"Kannada",Malayalam:"Malayalam",Odia:"Odia",Sinhala:"Sinhala",Tamil:"Tamil",Telugu:"Telugu",English:"Normal",Sanskrit:"Devanagari",Marathi:"Devanagari",Nepali:"Devanagari",Punjabi:"Gurumukhi",Assamese:"Assamese"},Ee={dev:"Devanagari",te:"Telugu",tel:"Telugu",tam:"Tamil","tam-ex":"Tamil-Extended",ben:"Bengali",be:"Bengali",ka:"Kannada",kan:"Kannada",gu:"Gujarati",guj:"Gujarati",mal:"Malayalam",or:"Odia",od:"Odia",oriya:"Odia",si:"Sinhala",sinh:"Sinhala",sin:"Sinhala",en:"Normal",eng:"Normal",la:"Normal",lat:"Normal",nor:"Normal",norm:"Normal",rom:"Romanized",gur:"Gurumukhi",as:"Assamese",sa:"Devanagari",san:"Devanagari",hin:"Devanagari",hi:"Devanagari",mar:"Devanagari",ne:"Devanagari",nep:"Devanagari",pun:"Gurumukhi"};function Ve(t){return t.toLowerCase().replace(/(^|-)([a-z])/g,(e,r,n)=>r+n.toUpperCase())}const F=t=>{const e=Ve(t);return ue.includes(e)?e:pe.includes(e)?He[e]:t.toLocaleLowerCase()in Ee?Ee[t.toLocaleLowerCase()]:null},Fe=async t=>{const e=F(t);if(!e)throw new Error(`Invalid script name: ${t}`);return await K(e)};async function Xe(t,e,r,n){const a=F(e);if(!a)throw new Error(`Invalid script name: ${e}`);const l=F(r);if(!l)throw new Error(`Invalid script name: ${r}`);return a===l?t:(await Ke(t,a,l,n)).output}async function We(t,e){const r=F(t);if(!r)throw new Error(`Invalid script name: ${t}`);const n=F(e);if(!n)throw new Error(`Invalid script name: ${e}`);const a=await K(r),l=await K(n);return Object.keys(ve(a,l,Object.fromEntries(Object.keys(te).map(i=>[i,!0]))))}const Se=4500,he=!0,me=!1;function qe(t,e){const{autoContextTClearTimeMs:r}=e??{};let n=e?.useNativeNumerals??he,a=e?.includeInherentVowel??me;const l=F(t);if(!l)throw new Error(`Invalid script name: ${t}`);let i="",o="";const u=r??Se;let _=null,s=null,c=null,p={},h=[];const f=(async()=>{const[w,y]=await Promise.all([K("Normal"),K(l)]);s=w,c=y;const X=xe(w,y);p=X.trans_options,h=X.custom_rules})();function d(){_=null,i="",o=""}function x(w){if(!s||!c)throw new Error("Typing context not ready. Await `ctx.ready` before calling takeKeyInputSync.");const y=Date.now();_&&y-_>u&&d();let X=w?.[0]??"";i+=X;let g=o;const{context_length:J,output:W}=Te(i,"Normal",l,s,c,p,h,{typing_mode:!0,useNativeNumerals:n,includeInherentVowel:a});J>0?o=W:J===0&&d();let T=0;for(;T<W.length&&T<g.length&&W[T]===g[T];)T++;let z=W.substring(T),ie=g.length-T;return _=Date.now(),{to_delete_chars_count:ie,diff_add_text:z}}return{ready:f,clearContext:d,takeKeyInput:x,updateUseNativeNumerals:w=>{n=w??he},updateIncludeInherentVowel:w=>{a=w??me}}}async function Ye(t,e,r,n){if(!(n??!0)){r?.(e?.currentTarget?.value);return}const l=e?.nativeEvent??e,i="nativeEvent"in e,o=e?.currentTarget??l?.target;if(!l||!o||l.isComposing)return;if(l.inputType!=="insertText"){r?.(o.value),t.clearContext();return}const u=l.data;if(typeof u!="string"||u.length!==1){r?.(o.value),t.clearContext();return}const _=o.selectionStart??0,s=o.selectionEnd??_;if(_!==s){r?.(o.value),t.clearContext();return}i&&r&&r(e.currentTarget.value),await t.ready;const{diff_add_text:c,to_delete_chars_count:p}=t.takeKeyInput(u),h=_,f=Math.max(0,h-p-u.length);o.setRangeText(c,f,h,"end"),r?.(o.value)}async function Qe(t,e,r,n){if(!(n??!0))return;const i="nativeEvent"in e?e.nativeEvent:e,o=e?.currentTarget??i?.target;if(!i||!o||i.isComposing||(!i.inputType||i.inputType!=="insertText")&&(!i.type||i.type!=="textInput"))return;const u=i.data;if(typeof u!="string"||u.length===0)return;if(u.length!==1){t.clearContext();return}const _=o.selectionStart??0,s=o.selectionEnd??_;if(_!==s){t.clearContext();return}i.preventDefault?.(),await t.ready;const{diff_add_text:c,to_delete_chars_count:p}=t.takeKeyInput(u),h=_,f=Math.max(0,h-p);o.setRangeText(c,f,h,"end"),r?.(o.value)}const Je=new Set(["Backspace","Delete","Enter","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Ze(t,e){const r=t?.nativeEvent??t;if(r instanceof KeyboardEvent){if(r.isComposing)return!1;const n=r.key;if(!n||n==="Unidentified"||n==="Process"||n==="Dead"||r.ctrlKey||r.metaKey||r.altKey)return!1;if(Je.has(n))return e.clearContext(),!0}return!1}async function et(t){const e=F(t);if(!e||e==="Normal")throw new Error(`Invalid script name: ${t}`);const r=await K(e);return r.krama_text_arr.map(a=>[a[0],r.list[a[1]??-1]?.type??"anya"])}async function tt(t){const e=F(t);if(!e||e==="Normal")throw new Error(`Invalid script name: ${t}`);const r=await K(e),n=l=>{const i=new Map,o=[],u=[];for(const[_,s,c]of l){const p=`${_}\0${s}`,h=i.get(p);if(h===void 0){const f=[],d=new Set;for(const x of c)d.has(x)||(d.add(x),f.push(x));u.push([_,s,f]),i.set(p,u.length-1),o.push(d)}else{const f=o[h],d=u[h][2];for(const x of c)f.has(x)||(f.add(x),d.push(x))}}return u.filter(([,,_])=>_.length>0)},a={common_krama_map:r.krama_text_arr.map(l=>[l[0],r.list[l[1]??-1]?.type??"anya",[]]),script_specific_krama_map:r.custom_script_chars_arr.map(l=>[l[0],r.list[l[1]??-1]?.type??"anya",[]])};for(let l=0;l<r.typing_text_to_krama_map.length;l++){const i=r.typing_text_to_krama_map[l],o=i[0];if(o!==""){if(i[1]&&i[1].custom_back_ref)a.script_specific_krama_map[i[1].custom_back_ref][2].push(o);else if(i[1]&&i[1].krama&&i[1].krama.length===1){const u=i[1].krama[0]??-1;u!==-1&&a.common_krama_map[u][2].push(o)}}}return a.common_krama_map=n(a.common_krama_map),a.script_specific_krama_map=n(a.script_specific_krama_map),a}const nt=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_AUTO_CONTEXT_CLEAR_TIME_MS:Se,DEFAULT_INCLUDE_INHERENT_VOWEL:me,DEFAULT_USE_NATIVE_NUMERALS:he,clearTypingContextOnKeyDown:Ze,createTypingContext:qe,getScriptKramaData:et,getScriptTypingDataMap:tt,handleTypingBeforeInputEvent:Qe,handleTypingInputEvent:Ye},Symbol.toStringTag,{value:"Module"}));O.ALL_LANG_SCRIPT_LIST=$e,O.LANG_LIST=pe,O.SCRIPT_LIST=ue,O.getAllOptions=We,O.preloadScriptData=Fe,O.transliterate=Xe,O.typing=nt,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/typing.d.ts
CHANGED
|
@@ -44,6 +44,29 @@ export declare const DEFAULT_INCLUDE_INHERENT_VOWEL = false;
|
|
|
44
44
|
/** Default values for the typing context options */
|
|
45
45
|
export declare const DEFAULT_USE_NATIVE_NUMERALS = true;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Functions to get the krama array for a script.
|
|
49
|
+
*
|
|
50
|
+
* It can be used to compare the krama array of two scripts.
|
|
51
|
+
* Especially useful for brahmic scripts, as they have a direct correlation
|
|
52
|
+
*
|
|
53
|
+
* @returns The krama array with corresponding type for the script
|
|
54
|
+
*/
|
|
55
|
+
export declare function getScriptKramaData(script: ScriptLangType): Promise<[text: string, type: ListType][]>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the typing data map for a script.
|
|
59
|
+
* @param script - The script to get the typing data map for
|
|
60
|
+
* @returns The typing data map for the script
|
|
61
|
+
*/
|
|
62
|
+
export declare function getScriptTypingDataMap(script: ScriptLangType): Promise<{
|
|
63
|
+
common_krama_map: [text: string, type: ListType, mappings: string[]][];
|
|
64
|
+
/** Contains mappings for script specific characters.
|
|
65
|
+
* uplicate key mappings are handled in the common_krama_map.
|
|
66
|
+
*/
|
|
67
|
+
script_specific_krama_map: [text: string, type: ListType, mappings: string[]][];
|
|
68
|
+
}>;
|
|
69
|
+
|
|
47
70
|
/**
|
|
48
71
|
* Handles `beforeinput` events for transliteration typing in `input` and `textarea` elements.
|
|
49
72
|
*
|
|
@@ -89,6 +112,8 @@ declare const lang_list: {
|
|
|
89
112
|
|
|
90
113
|
declare type lang_list_type = keyof typeof lang_list;
|
|
91
114
|
|
|
115
|
+
declare type ListType = 'svara' | 'vyanjana' | 'anya' | 'mAtrA';
|
|
116
|
+
|
|
92
117
|
declare type script_and_lang_list_type = script_list_type | lang_list_type;
|
|
93
118
|
|
|
94
119
|
declare type script_input_name_type = alternate_script_type | script_and_lang_list_type;
|