lipilekhika 0.0.0-alpha.21 → 0.0.0-alpha.22

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.
Files changed (91) hide show
  1. package/dist/cjs/Assamese-Dv2Uz5Ga.cjs +1 -0
  2. package/dist/cjs/Bengali-CP-jqwb3.cjs +1 -0
  3. package/dist/cjs/Brahmi-BOnETq6u.cjs +1 -0
  4. package/dist/cjs/Devanagari-DogoRXY8.cjs +1 -0
  5. package/dist/cjs/Granth-9Z5eCctH.cjs +1 -0
  6. package/dist/cjs/Gujarati-CUm-ZsKN.cjs +1 -0
  7. package/dist/cjs/Gurumukhi-CsObr-GI.cjs +1 -0
  8. package/dist/cjs/Kannada-SXQdSng_.cjs +1 -0
  9. package/dist/cjs/Malayalam-IcKWWsaB.cjs +1 -0
  10. package/dist/cjs/Modi-C3Chvoab.cjs +1 -0
  11. package/dist/cjs/Normal-BZe6xAux.cjs +1 -0
  12. package/dist/cjs/Odia-C_-bjsx6.cjs +1 -0
  13. package/dist/cjs/Purna-Devanagari-BkPRDmig.cjs +1 -0
  14. package/dist/cjs/Romanized-B_o6BaP0.cjs +1 -0
  15. package/dist/cjs/Sharada-DfQQFnhQ.cjs +1 -0
  16. package/dist/cjs/Siddham-D4xax5q5.cjs +1 -0
  17. package/dist/cjs/Sinhala-oz5fU6-H.cjs +1 -0
  18. package/dist/cjs/Tamil-Extended-Bg0_zDSf.cjs +1 -0
  19. package/dist/cjs/Tamil-pc27DGFa.cjs +1 -0
  20. package/dist/cjs/Telugu-C9jvVXuj.cjs +1 -0
  21. package/dist/cjs/index.cjs +2 -0
  22. package/dist/esm/Assamese-C2ZNJvdv.js +25 -0
  23. package/dist/esm/Bengali-B4lwiGw-.js +25 -0
  24. package/dist/esm/Brahmi-P_BhbEU1.js +23 -0
  25. package/dist/esm/Devanagari-CU6oiaDU.js +25 -0
  26. package/dist/esm/Granth-v69SsV6n.js +25 -0
  27. package/dist/esm/Gujarati-GMDcD3zf.js +25 -0
  28. package/dist/esm/Gurumukhi-cSQGlqXa.js +25 -0
  29. package/dist/esm/Kannada-BC0s2WZG.js +25 -0
  30. package/dist/esm/Malayalam-R6qN3iwf.js +23 -0
  31. package/dist/esm/Modi-B8YiZBXf.js +23 -0
  32. package/dist/esm/Normal-DH6dfVGR.js +21 -0
  33. package/dist/esm/Odia-DphK-sRO.js +25 -0
  34. package/dist/esm/Purna-Devanagari-iW765mfa.js +25 -0
  35. package/dist/esm/Romanized-BQU9AmMX.js +21 -0
  36. package/dist/esm/Sharada-DOmuoJ5u.js +25 -0
  37. package/dist/esm/Siddham-CZ7F2rJg.js +25 -0
  38. package/dist/esm/Sinhala-BKPrzGBh.js +23 -0
  39. package/dist/esm/Tamil-B_Q1LP6g.js +23 -0
  40. package/dist/esm/Tamil-Extended-8h88s1_g.js +23 -0
  41. package/dist/esm/Telugu-w-eiYYTU.js +23 -0
  42. package/dist/esm/index.mjs +764 -0
  43. package/dist/index.d.ts +668 -0
  44. package/dist/lipilekhika.umd.js +1 -1
  45. package/dist/tsdoc-metadata.json +11 -0
  46. package/package.json +1 -1
  47. package/dist/types/src/custom_options.json.d.ts +0 -220
  48. package/dist/types/src/index.d.ts +0 -100
  49. package/dist/types/src/make_script_data/custom_options_input.d.ts +0 -62
  50. package/dist/types/src/make_script_data/input_data/Assamese.d.ts +0 -3
  51. package/dist/types/src/make_script_data/input_data/Bengali.d.ts +0 -3
  52. package/dist/types/src/make_script_data/input_data/Brahmi.d.ts +0 -3
  53. package/dist/types/src/make_script_data/input_data/Devanagari.d.ts +0 -3
  54. package/dist/types/src/make_script_data/input_data/Granth.d.ts +0 -3
  55. package/dist/types/src/make_script_data/input_data/Gujarati.d.ts +0 -3
  56. package/dist/types/src/make_script_data/input_data/Gurumukhi.d.ts +0 -3
  57. package/dist/types/src/make_script_data/input_data/Kannada.d.ts +0 -3
  58. package/dist/types/src/make_script_data/input_data/Malayalam.d.ts +0 -3
  59. package/dist/types/src/make_script_data/input_data/Modi.d.ts +0 -3
  60. package/dist/types/src/make_script_data/input_data/Normal.d.ts +0 -3
  61. package/dist/types/src/make_script_data/input_data/Odia.d.ts +0 -3
  62. package/dist/types/src/make_script_data/input_data/Purna-Devanagari.d.ts +0 -3
  63. package/dist/types/src/make_script_data/input_data/Romanized.d.ts +0 -3
  64. package/dist/types/src/make_script_data/input_data/Sharada.d.ts +0 -3
  65. package/dist/types/src/make_script_data/input_data/Siddham.d.ts +0 -3
  66. package/dist/types/src/make_script_data/input_data/Sinhala.d.ts +0 -3
  67. package/dist/types/src/make_script_data/input_data/Tamil-Extended.d.ts +0 -3
  68. package/dist/types/src/make_script_data/input_data/Tamil.d.ts +0 -3
  69. package/dist/types/src/make_script_data/input_data/Telugu.d.ts +0 -3
  70. package/dist/types/src/make_script_data/input_script_data_schema.d.ts +0 -91
  71. package/dist/types/src/make_script_data/krama_array_keys.d.ts +0 -145
  72. package/dist/types/src/make_script_data/make_output_script_data.d.ts +0 -1
  73. package/dist/types/src/make_script_data/output_script_data_schema.d.ts +0 -46
  74. package/dist/types/src/tools/kry.d.ts +0 -18
  75. package/dist/types/src/transliteration/a.d.ts +0 -1
  76. package/dist/types/src/transliteration/active_option_resolver.test.d.ts +0 -1
  77. package/dist/types/src/transliteration/context_clear.test.d.ts +0 -1
  78. package/dist/types/src/transliteration/emulate_typing.test.d.ts +0 -1
  79. package/dist/types/src/transliteration/helpers.d.ts +0 -90
  80. package/dist/types/src/transliteration/test_commons.d.ts +0 -13
  81. package/dist/types/src/transliteration/transliterate.d.ts +0 -47
  82. package/dist/types/src/transliteration/transliterate.test.d.ts +0 -2
  83. package/dist/types/src/utils/binary_search/binary_search.d.ts +0 -25
  84. package/dist/types/src/utils/binary_search/binary_search.test.d.ts +0 -1
  85. package/dist/types/src/utils/get_script_data.d.ts +0 -8
  86. package/dist/types/src/utils/lang_list/index.d.ts +0 -50
  87. package/dist/types/src/utils/lang_list/langs.json.d.ts +0 -44
  88. package/dist/types/src/utils/lang_list/script_normalization.d.ts +0 -6
  89. package/dist/types/src/utils/lang_list/script_normalization.test.d.ts +0 -1
  90. package/dist/types/src/utils/non_bmp.d.ts +0 -3
  91. package/dist/types/src/utils/runtime_macros.d.ts +0 -5
@@ -1,2 +1,2 @@
1
- (function(g,L){typeof exports=="object"&&typeof module<"u"?L(exports):typeof define=="function"&&define.amd?define(["exports"],L):(g=typeof globalThis<"u"?globalThis:g||self,L(g.lipilekhika={}))})(this,(function(g){"use strict";function L(t,e,r,n){const{accessor:a,compareFn:s}=n??{},c=a??((i,l)=>i[l]);let u=0,_=e.length-1,o=-1;for(;u<=_;){const i=Math.floor((u+_)/2),l=e[i],p=c(t,l);let h;s?h=s(r,p):h=r<p?-1:r>p?1:0,h===0?(o=l,_=i-1):h<0?_=i-1:u=i+1}return o}function ee(t,e,r){const{accessor:n,compareFn:a}=r??{},s=n??((o,i)=>o[i]);let c=0,u=t.length-1,_=-1;for(;c<=u;){const o=Math.floor((c+u)/2),i=s(t,o);let l;a?l=a(e,i):l=e<i?-1:e>i?1:0,l===0?(_=o,u=o-1):l<0?u=o-1:c=o+1}return _}const te={},M=async t=>{{if(te[t])return te[t];const r=`https://cdn.jsdelivr.net/npm/lipilekhika@0.0.0-alpha.21/dist/umd_json/script_data/${t}.json`,a=(await fetch(r)).json();return te[t]=a,a}},V={"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_anuvsvAra":{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_conjuct_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]}]}},de=(t,e)=>{const r=t.krama_text_arr[e]?.[0];return typeof r=="string"?r:null},j=(t,e)=>de(t,e)??"",Y=(t,e)=>L(t.krama_text_arr,t.krama_text_arr_index,e,{accessor:(r,n)=>r[n][0]}),ge=()=>{let t=[];function e(i){i&&t.push(i)}function r(i){for(const l of i)e(l)}function n(){return t.at(-1)}function a(){return n()?.at(-1)}function s(){const i=n();if(!i)return;const l=i.at(-1),p=i.slice(0,-1);return p?t[t.length-1]=p:t.pop(),l}function c(i,l){t.splice(-i,i,...l.filter(Boolean))}function u(i,l){const p=s();if(!p){r(i),r(l);return}r(i),e(p),r(l)}function _(i){const l=t.at(i);return l?{cp:i,ch:l,width:l.length}:null}function o(i,l){i<0&&(i=t.length+i),!(i<0||i>=t.length)&&(t[i]=l)}return{emit:e,emitPieces:r,lastPiece:n,lastChar:a,popLastChar:s,rewriteTailPieces:c,withLastCharMovedAfter:u,toString:()=>t.join(""),rewriteAt:o,peekAt:_}},ve=t=>{let e=[];function r(){e=[]}function n(){return e.length}function a(p){return e.at(p)}function s(){return e.at(-1)}function c(){return s()?.[0]}function u(){return s()?.[1]?.type}function _(p){return a(p)?.[1]?.type}function o(p){return a(p)?.[0]}function i(p){return u()===p}function l(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:s,lastText:c,lastType:u,typeAt:_,textAt:o,isLastType:i,push:l}},xe=t=>{let e=0;function r(u){const _=t.codePointAt(u);if(_===void 0)return null;const o=String.fromCodePoint(_);return{cp:_,ch:o,width:o.length}}function n(){return r(e)}function a(u){return r(e+u)}function s(u){e+=u}function c(u,_){return t.substring(u,_)}return{get pos(){return e},peek:n,peekAt:r,peekAtOffsetUnits:a,advance:s,slice:c}},ne=(t,e,r,n)=>{for(let a=0;a<r.length;a++){const s=r[r.length-1-a],c=t(e-a);if(c===null)return{matched:!1,matchedLen:0};const u=Y(n,c.ch);if(u===-1||u!==s)return{matched:!1,matchedLen:0}}return{matched:!0,matchedLen:r.length}},ae=(t,e)=>t.map(r=>j(e,r)).filter(Boolean),Ae=["²","³","⁴"],I=t=>!!t&&Ae.indexOf(t)!==-1,P=t=>t==="Tamil-Extended",B=(t,e,r,n)=>{if(e.length===0)return;if(!n){t.emitPieces(e);return}const a=e[0]??"";if(a[0]===r){const s=a.slice(1),c=[];s&&c.push(s);for(let u=1;u<e.length;u++)c.push(e[u]);t.withLastCharMovedAfter([r],c)}else t.withLastCharMovedAfter(e,[])},we=[" ",`
1
+ (function(g,L){typeof exports=="object"&&typeof module<"u"?L(exports):typeof define=="function"&&define.amd?define(["exports"],L):(g=typeof globalThis<"u"?globalThis:g||self,L(g.lipilekhika={}))})(this,(function(g){"use strict";function L(t,e,r,n){const{accessor:a,compareFn:s}=n??{},c=a??((i,l)=>i[l]);let u=0,_=e.length-1,o=-1;for(;u<=_;){const i=Math.floor((u+_)/2),l=e[i],p=c(t,l);let h;s?h=s(r,p):h=r<p?-1:r>p?1:0,h===0?(o=l,_=i-1):h<0?_=i-1:u=i+1}return o}function ee(t,e,r){const{accessor:n,compareFn:a}=r??{},s=n??((o,i)=>o[i]);let c=0,u=t.length-1,_=-1;for(;c<=u;){const o=Math.floor((c+u)/2),i=s(t,o);let l;a?l=a(e,i):l=e<i?-1:e>i?1:0,l===0?(_=o,u=o-1):l<0?u=o-1:c=o+1}return _}const te={},M=async t=>{{if(te[t])return te[t];const r=`https://cdn.jsdelivr.net/npm/lipilekhika@0.0.0-alpha.22/dist/umd_json/script_data/${t}.json`,a=(await fetch(r)).json();return te[t]=a,a}},V={"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_anuvsvAra":{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_conjuct_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]}]}},de=(t,e)=>{const r=t.krama_text_arr[e]?.[0];return typeof r=="string"?r:null},j=(t,e)=>de(t,e)??"",Y=(t,e)=>L(t.krama_text_arr,t.krama_text_arr_index,e,{accessor:(r,n)=>r[n][0]}),ge=()=>{let t=[];function e(i){i&&t.push(i)}function r(i){for(const l of i)e(l)}function n(){return t.at(-1)}function a(){return n()?.at(-1)}function s(){const i=n();if(!i)return;const l=i.at(-1),p=i.slice(0,-1);return p?t[t.length-1]=p:t.pop(),l}function c(i,l){t.splice(-i,i,...l.filter(Boolean))}function u(i,l){const p=s();if(!p){r(i),r(l);return}r(i),e(p),r(l)}function _(i){const l=t.at(i);return l?{cp:i,ch:l,width:l.length}:null}function o(i,l){i<0&&(i=t.length+i),!(i<0||i>=t.length)&&(t[i]=l)}return{emit:e,emitPieces:r,lastPiece:n,lastChar:a,popLastChar:s,rewriteTailPieces:c,withLastCharMovedAfter:u,toString:()=>t.join(""),rewriteAt:o,peekAt:_}},ve=t=>{let e=[];function r(){e=[]}function n(){return e.length}function a(p){return e.at(p)}function s(){return e.at(-1)}function c(){return s()?.[0]}function u(){return s()?.[1]?.type}function _(p){return a(p)?.[1]?.type}function o(p){return a(p)?.[0]}function i(p){return u()===p}function l(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:s,lastText:c,lastType:u,typeAt:_,textAt:o,isLastType:i,push:l}},xe=t=>{let e=0;function r(u){const _=t.codePointAt(u);if(_===void 0)return null;const o=String.fromCodePoint(_);return{cp:_,ch:o,width:o.length}}function n(){return r(e)}function a(u){return r(e+u)}function s(u){e+=u}function c(u,_){return t.substring(u,_)}return{get pos(){return e},peek:n,peekAt:r,peekAtOffsetUnits:a,advance:s,slice:c}},ne=(t,e,r,n)=>{for(let a=0;a<r.length;a++){const s=r[r.length-1-a],c=t(e-a);if(c===null)return{matched:!1,matchedLen:0};const u=Y(n,c.ch);if(u===-1||u!==s)return{matched:!1,matchedLen:0}}return{matched:!0,matchedLen:r.length}},ae=(t,e)=>t.map(r=>j(e,r)).filter(Boolean),Ae=["²","³","⁴"],I=t=>!!t&&Ae.indexOf(t)!==-1,P=t=>t==="Tamil-Extended",B=(t,e,r,n)=>{if(e.length===0)return;if(!n){t.emitPieces(e);return}const a=e[0]??"";if(a[0]===r){const s=a.slice(1),c=[];s&&c.push(s);for(let u=1;u<e.length;u++)c.push(e[u]);t.withLastCharMovedAfter([r],c)}else t.withLastCharMovedAfter(e,[])},we=[" ",`
2
2
  `,"\r"," ",",",";","!","@","?","%"],Te=3;function b(t,e,r){const{from_script_name:n,to_script_name:a,from_script_data:s,to_script_data:c,trans_options:u,result:_,prev_context:o,BRAHMIC_HALANT:i,BRAHMIC_NUQTA:l,typing_mode:p}=t,{next:h,last_extra_call:d}=r??{};let v=!1;if((l&&o.typeAt(-3)==="vyanjana"&&o.textAt(-2)===l&&o.typeAt(-1)==="mAtrA"||o.typeAt(-2)==="vyanjana"&&o.typeAt(-1)==="mAtrA")&&(!e||e[1]?.type==="anya")&&o.clear(),s.script_type==="brahmic"&&c.script_type==="other")e[0]!==i&&(!(P(n)&&e[0]&&e[0].length>0)||e[0].charAt(0)!==i)&&(!l||e[0]!==l)&&(o.typeAt(-1)==="vyanjana"||l&&o.typeAt(-2)==="vyanjana"&&o.textAt(-1)===l)&&(e[1]?.type!=="mAtrA"&&e[0]!==i||e[1]?.type==="anya"||e[1]===null||e[1]===void 0)&&_.emit(c.schwa_character);else if(s.script_type==="other"&&c.script_type==="brahmic")if(o.typeAt(-1)==="vyanjana"&&(e[1]?.type==="mAtrA"||e[1]?.type==="svara")){const k=e[1].type==="svara"?j(c,e[1].mAtrA_krama_ref?.[0]??-1):e[0];P(a)&&I(_.lastChar())?B(_,[k],c.halant,!0):B(_,[k],c.halant,!1),v=!0}else o.typeAt(-1)==="vyanjana"&&!(e[0]===i||e[1]?.type==="mAtrA")&&(P(a)&&I(_.lastChar())?B(_,[i],c.halant,!0):(B(_,[i],c.halant,!1),a==="Sinhala"&&u["all_to_sinhala:use_conjuct_enabling_halant"]&&_.rewriteAt(-1,_.lastPiece()+"‍")));let m=!1;return p&&(h===void 0||h.length===0)&&!d&&(m=!0,e[1]?.type==="vyanjana"&&(m=!1),m&&o.clear()),(!p||!d&&!m)&&o.push(e),v}function ue(t,e,r){const{custom_rules:n,cursor:a,result:s,from_script_data:c,to_script_data:u}=t,_=e+r;for(let o=0;o<n.length;o++){if(n[o].use_replace===!0)continue;const i=n[o];if(i.type==="replace_prev_krama_keys"){if(i.check_in==="input"){const l=ne(a.peekAt,_,i.prev,c),p=a.peekAt(e);if(l.matched&&p!==null){const h=p.ch,d=Y(c,h);if(d!==-1&&i.following.indexOf(d)!==-1){const v=ae(i.replace_with,u);s.rewriteTailPieces(l.matchedLen,v)}}}else if(i.check_in==="output"){const l=s.lastPiece();if(!l)continue;const p=Y(u,l);if(p!==-1&&i.following.indexOf(p)!==-1){const h=ne(s.peekAt,-2,i.prev,u);if(h.matched){const d=ae(i.replace_with,u);s.rewriteTailPieces(h.matchedLen+1,[...d,l])}}}}else if(i.type==="direct_replace"){const l=i.check_in==="output"?u:c;for(const p of i.to_replace){const h=ne(s.peekAt,-1,p,l);if(!h.matched)continue;if(i.replace_text){s.rewriteTailPieces(h.matchedLen,[i.replace_text]);break}const d=ae(i.replace_with,l);s.rewriteTailPieces(h.matchedLen,d);break}}}}const _e=(t,e,r)=>{if(!r)return{};const n={};for(const[a,s]of Object.entries(r??{})){if(!s||!(a in V))continue;const c=V[a];(c.from_script_type!==void 0&&(c.from_script_type==="all"||c.from_script_type===t.script_type)||c.from_script_name!==void 0&&c.from_script_name.includes(t.script_name))&&(c.to_script_type!==void 0&&(c.to_script_type==="all"||c.to_script_type===e.script_type)||c.to_script_name!==void 0&&c.to_script_name.includes(e.script_name))&&(n[a]=!0)}return n},pe=(t,e,r)=>{const n=_e(t,e,r),a=Object.keys(n).flatMap(s=>V[s].rules);return{trans_options:n,custom_rules:a}},he=(t,e)=>t.replace_with.map(r=>j(e,r)).join(""),fe=(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 s=a.prev.map(c=>j(e,c)).join("");for(let c of a.following){const u=j(e,c);if(!u)continue;const _=he(a,e)+u;t=t.replaceAll(s+u,_)}}else if(a.type==="direct_replace"){const s=a.to_replace.map(c=>c.map(u=>j(e,u)).join(""));for(let c of s)t=t.replaceAll(c,he(a,e))}}return t},me=(t,e,r,n,a,s,c,u)=>{const _=u?.typing_mode??!1;if(_&&e!=="Normal")throw new Error("Typing mode is only supported with Normal script as the input");t=fe(t,n,c,"input");const o=ge();let i=0;const l=xe(t),p=ve(Te),h=n.script_type==="brahmic"&&a.script_type==="other"||n.script_type==="other"&&a.script_type==="brahmic"||_&&e==="Normal"&&a.script_type==="other",d=n.script_type==="brahmic"&&a.script_type==="other"?n.nuqta??null:n.script_type==="other"&&a.script_type==="brahmic"?a.nuqta??null:null,v=n.script_type==="brahmic"&&a.script_type==="other"?n.halant:n.script_type==="other"&&a.script_type==="brahmic"?a.halant:null,m={from_script_name:e,to_script_name:r,from_script_data:n,to_script_data:a,trans_options:s,custom_rules:c,cursor:l,result:o,prev_context:p,BRAHMIC_NUQTA:d,BRAHMIC_HALANT:v,typing_mode:_};let k=-1;for(;l.pos<t.length;){i=l.pos;const le=l.peek();if(!le)break;const ce=le.ch,H=le.width,ke=H===2?1:H;if(k!==-1&&i>=k){k=-1,l.advance(H);continue}if(we.indexOf(ce)!==-1){l.advance(H),h&&(b(m,[" ",null]),p.clear()),o.emit(ce);continue}let G=-1;{let S=0,U=-1;const E=h&&n.script_type==="other"&&a.script_type==="brahmic"&&(p.typeAt(-1)==="vyanjana"||d&&p.typeAt(-2)==="vyanjana"&&p.textAt(-1)===d);for(;;){const Z=l.peekAt(i+ke+S),O=Z?.ch??"";k!==-1&&O&&I(O)&&(S+=Z?.width??0);const y=i+ke+S,T=k!==-1?l.slice(i,k)+(y>k?l.slice(k+1,y):""):l.slice(i,y),x=ee(n.text_to_krama_map,T,{accessor:(A,N)=>A[N][0]});if(x===-1){G=-1;break}const D=n.text_to_krama_map[x];if(E&&D[1].krama&&D[1].krama.length>=1){const A=D[1].krama,N=A[0],C=a.krama_text_arr[N]?.[1],se=a.list[C??-1]?.type;if(A.length===1&&C!==null&&C!==void 0&&(se==="svara"||se==="mAtrA"))U=x;else if(U!==-1){G=U;break}}if(D[1].next&&D[1].next.length>0){const A=l.peekAt(y),N=A?.ch;if(P(e)&&n.script_type==="brahmic"){const q=A?l.peekAt(y+A.width):null,C=q?.ch,F=(A&&q?l.peekAt(y+A.width+q.width):null)?.ch;if(k===-1&&C!==void 0&&I(C)&&D[1].next.indexOf(C)!==-1){const W=ee(n.text_to_krama_map,T+C,{accessor:(R,w)=>R[w][0]}),Q=L(n.krama_text_arr,n.krama_text_arr_index,N??"",{accessor:(R,w)=>R[w][0]});if(W!==-1&&Q!==-1){G=W;const R=n.krama_text_arr[Q],w=n.list[R[1]??-1]?.type;if(N===n.halant||w==="mAtrA"){k=y+(A?.width??0);break}}}else if(k===-1&&F!==void 0&&I(F)&&D[1].next.indexOf(F)!==-1){const W=ee(n.text_to_krama_map,T+F,{accessor:(w,K)=>w[K][0]}),Q=L(n.krama_text_arr,n.krama_text_arr_index,N??"",{accessor:(w,K)=>w[K][0]}),R=L(n.krama_text_arr,n.krama_text_arr_index,C??"",{accessor:(w,K)=>w[K][0]});if(W!==-1&&Q!==-1&&R!==-1){const w=n.krama_text_arr[Q],K=n.krama_text_arr[R];G=W;const Be=n.list[w[1]??-1]?.type,ze=n.list[K[1]??-1]?.type;if(Be==="mAtrA"&&ze==="mAtrA"){k=y+(A?.width??0)+(q?.width??0);break}}}}if(N!==void 0&&D[1].next.indexOf(N)!==-1){S+=A?.width??0;continue}}G=x;break}}const f=G!==-1?n.text_to_krama_map[G]:null;if(f!==null){const S=k!==-1&&f[0].length>1&&n.list[n.krama_text_arr[f[1].krama?.[0]??-1]?.[1]??-1]?.type==="vyanjana"&&I(f[0].at(-1)??void 0)?1:0,U=f[0].length-S;if(l.advance(U),i=l.pos,f[1].krama!==null&&f[1].krama!==void 0&&f[1].krama.some(E=>E!==-1)){const E=f[1].krama.map(y=>j(a,y)),Z=E.join("");let O=!1;if(h)if(n.script_type==="brahmic"&&a.script_type==="other"){let y=null;if(f[1].fallback_list_ref!==void 0&&f[1].fallback_list_ref!==null)y=n.list[f[1].fallback_list_ref];else if(!f[1].krama||f[1].krama.length===0)y=null;else{const T=f[1].krama.map(x=>n.list[n.krama_text_arr[x][1]??-1]);P(e)&&T.some(x=>x?.type==="mAtrA")&&T.some(x=>x?.type==="vyanjana")?y={...T[0],type:"anya"}:P(e)&&T.length>1&&T.some(x=>x==null)?y=T.at(-1):y=T[0]}O=b(m,[f[0],y])}else if(a.script_type==="brahmic"&&n.script_type==="other"){let y=null;f[1].fallback_list_ref!==void 0&&f[1].fallback_list_ref!==null?y=a.list[f[1].fallback_list_ref]:y=f[1].krama&&f[1].krama.length>0?a.list[a.krama_text_arr[f[1].krama[0]]?.[1]??-1]??null:null,_&&e==="Normal"?O=b(m,[f[0],y],{next:f[1].next??void 0}):O=b(m,[f[0],y])}else _&&e==="Normal"&&a.script_type==="other"&&(O=b(m,[f[0],null],{next:f[1].next??void 0}));O||(a.script_type==="brahmic"&&P(r)&&(a.list[f[1].krama?.at(-1)??-1]?.type==="mAtrA"||Z===a.halant)&&I(o.lastChar())?B(o,E,a.halant,!0):o.emitPieces(E)),ue(m,i,-U);continue}else if(f[1].krama!==null&&f[1].krama!==void 0&&f[1].krama.some(E=>E===-1)){o.emit(f[0]),_&&b(m,[f[0],null],{next:f[1].next??void 0});continue}}else l.advance(H),i=l.pos;const $=f===null?ce:f[0],X=Y(n,$);if(X===-1){h&&(b(m,[$,null]),p.clear()),o.emit($);continue}let oe=!1;if(h&&(n.script_type==="brahmic"?oe=b(m,[$,n.list[n.krama_text_arr[X][1]??-1]]):a.script_type==="brahmic"&&(oe=b(m,[$,a.list[a.krama_text_arr[X][1]??-1]]))),!oe){const S=j(a,X);a.script_type==="brahmic"&&P(r)&&(a.list[a.krama_text_arr[X][1]??-1]?.type==="mAtrA"||S===a.halant)&&I(o.lastChar())?B(o,[S],a.halant,!0):o.emit(S)}ue(m,i,-H)}h&&b(m,[void 0,null],{last_extra_call:!0});let J=o.toString();return J=fe(J,a,c,"output"),{output:J,context_length:p.length()}},be=async(t,e,r,n,a)=>{const[s,c]=await Promise.all([M(e),M(r)]),{trans_options:u,custom_rules:_}=pe(s,c,n);return me(t,e,r,s,c,u,_,a)},Se={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:Ee,lang_list:Ne}=Se,re=Object.keys(Ee),ie=Object.keys(Ne),Ce=Array.from(new Set([...ie,...re])),Le={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"},ye={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 je(t){return t.toLowerCase().replace(/(^|-)([a-z])/g,(e,r,n)=>r+n.toUpperCase())}const z=t=>{const e=je(t);return re.includes(e)?e:ie.includes(e)?Le[e]:t.toLocaleLowerCase()in ye?ye[t.toLocaleLowerCase()]:null},Ie=async t=>{const e=z(t);if(!e)throw new Error(`Invalid script name: ${t}`);return await M(e)};async function Pe(t,e,r,n){const a=z(e);if(!a)throw new Error(`Invalid script name: ${e}`);const s=z(r);if(!s)throw new Error(`Invalid script name: ${r}`);return a===s?t:(await be(t,a,s,n)).output}async function Oe(t,e){const r=z(t);if(!r)throw new Error(`Invalid script name: ${t}`);const n=z(e);if(!n)throw new Error(`Invalid script name: ${e}`);const a=await M(r),s=await M(n);return Object.keys(_e(a,s,Object.fromEntries(Object.keys(V).map(c=>[c,!0]))))}function De(t){const e=z(t);if(!e)throw new Error(`Invalid script name: ${t}`);let r="",n="",a=null,s=null,c={},u=[];const _=(async()=>{const[l,p]=await Promise.all([M("Normal"),M(e)]);a=l,s=p;const h=pe(l,p);c=h.trans_options,u=h.custom_rules})();function o(){r="",n=""}function i(l){if(!a||!s)throw new Error("Typing context not ready. Await `ctx.ready` before calling takeKeyInputSync.");let p=l?.[0]??"";r+=p;let h=n;const{context_length:d,output:v}=me(r,"Normal",e,a,s,c,u,{typing_mode:!0});d>0?n=v:d===0&&(r="",n="");let m=0;for(;m<v.length&&m<h.length&&v[m]===h[m];)m++;let k=v.substring(m);return{to_delete_chars_count:h.length-m,diff_add_text:k}}return{ready:_,clearContext:o,takeKeyInput:i,getCurrentOutput:()=>n}}function Re(t){return"nativeEvent"in t?t.nativeEvent:t}async function Me(t,e,r){const n=e.currentTarget,a=Re(e);if(typeof InputEvent<"u"&&a instanceof InputEvent&&a.data!==null){await t.ready;const{diff_add_text:c,to_delete_chars_count:u}=t.takeKeyInput(a.data),_=n.value,o=(n.selectionStart??0)+1,i=o-u-2,l=_.substring(0,i),p=c;let h="";const d=_.length+1===o,v=_.length+1!==o;d?h=_.substring(o+1):v&&(h=_.substring(o-1));const m=l.length+p.length,k=l+p+h;n.value=k,n.focus(),n.selectionStart=m,n.selectionEnd=m,r?.(k)}else r?.(n.value),t.clearContext()}const Ge=new Set(["Backspace","Delete","Enter","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Ke(t,e){if(t.isComposing)return!1;const r=t.key;return!r||r==="Unidentified"||r==="Process"||r==="Dead"||t.ctrlKey||t.metaKey||t.altKey?!1:Ge.has(r)?(e.clearContext(),!0):!1}g.ALL_LANG_SCRIPT_LIST=Ce,g.LANG_LIST=ie,g.SCRIPT_LIST=re,g.clearTypingContextOnKeyDown=Ke,g.createTypingContext=De,g.getAllOptions=Oe,g.handleTypingInputEvent=Me,g.preloadScriptData=Ie,g.transliterate=Pe,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.55.2"
9
+ }
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lipilekhika",
3
- "version": "0.0.0-alpha.21",
3
+ "version": "0.0.0-alpha.22",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/shubhattin/lipilekhika/tree/main/packages/js",
@@ -1,220 +0,0 @@
1
- declare const _default: {
2
- "all_to_normal:replace_pancham_varga_varna_with_n": {
3
- "from_script_type": "all",
4
- "to_script_name": [
5
- "Normal"
6
- ],
7
- "check_in": "output",
8
- "rules": [
9
- {
10
- "type": "replace_prev_krama_keys",
11
- "check_in": "output",
12
- "prev": [
13
- 60
14
- ],
15
- "following": [
16
- 52,
17
- 53,
18
- 54,
19
- 55,
20
- 56,
21
- 57,
22
- 58,
23
- 59
24
- ],
25
- "replace_with": [
26
- 72
27
- ]
28
- },
29
- {
30
- "type": "replace_prev_krama_keys",
31
- "check_in": "output",
32
- "prev": [
33
- 67
34
- ],
35
- "following": [
36
- 61,
37
- 62,
38
- 63,
39
- 64,
40
- 65,
41
- 66
42
- ],
43
- "replace_with": [
44
- 72
45
- ]
46
- }
47
- ]
48
- },
49
- "brahmic_to_brahmic:replace_pancham_varga_varna_with_anuvsvAra": {
50
- "from_script_type": "brahmic",
51
- "to_script_type": "brahmic",
52
- "check_in": "input",
53
- "rules": [
54
- {
55
- "type": "replace_prev_krama_keys",
56
- "check_in": "input",
57
- "prev": [
58
- 60,
59
- 49
60
- ],
61
- "following": [
62
- 52,
63
- 53,
64
- 54,
65
- 55,
66
- 56,
67
- 57,
68
- 58,
69
- 59
70
- ],
71
- "replace_with": [
72
- 45
73
- ]
74
- },
75
- {
76
- "type": "replace_prev_krama_keys",
77
- "check_in": "input",
78
- "prev": [
79
- 67,
80
- 49
81
- ],
82
- "following": [
83
- 61,
84
- 62,
85
- 63,
86
- 64,
87
- 65,
88
- 66
89
- ],
90
- "replace_with": [
91
- 45
92
- ]
93
- },
94
- {
95
- "type": "replace_prev_krama_keys",
96
- "check_in": "input",
97
- "prev": [
98
- 81,
99
- 49
100
- ],
101
- "following": [
102
- 74,
103
- 75,
104
- 76,
105
- 77,
106
- 78,
107
- 79,
108
- 80
109
- ],
110
- "replace_with": [
111
- 45
112
- ]
113
- },
114
- {
115
- "type": "replace_prev_krama_keys",
116
- "check_in": "input",
117
- "prev": [
118
- 72,
119
- 49
120
- ],
121
- "following": [
122
- 68,
123
- 69,
124
- 70,
125
- 71
126
- ],
127
- "replace_with": [
128
- 45
129
- ]
130
- },
131
- {
132
- "type": "replace_prev_krama_keys",
133
- "check_in": "input",
134
- "prev": [
135
- 88,
136
- 49
137
- ],
138
- "following": [
139
- 82,
140
- 83,
141
- 85,
142
- 86,
143
- 87
144
- ],
145
- "replace_with": [
146
- 45
147
- ]
148
- }
149
- ]
150
- },
151
- "all_to_sinhala:use_conjuct_enabling_halant": {
152
- "from_script_type": "all",
153
- "to_script_name": [
154
- "Sinhala"
155
- ],
156
- "check_in": "output",
157
- "rules": [
158
- {
159
- "type": "direct_replace",
160
- "check_in": "output",
161
- "to_replace": [
162
- [
163
- 49
164
- ]
165
- ],
166
- "replace_text": "්‍",
167
- "replace_with": []
168
- }
169
- ]
170
- },
171
- "all_to_normal:remove_virAma_and_double_virAma": {
172
- "from_script_type": "all",
173
- "to_script_name": [
174
- "Normal",
175
- "Romanized"
176
- ],
177
- "check_in": "output",
178
- "rules": [
179
- {
180
- "type": "direct_replace",
181
- "check_in": "output",
182
- "to_replace": [
183
- [
184
- 116
185
- ],
186
- [
187
- 115
188
- ]
189
- ],
190
- "replace_with": [
191
- -1
192
- ]
193
- }
194
- ]
195
- },
196
- "all_to_normal:replace_avagraha_with_a": {
197
- "from_script_type": "all",
198
- "to_script_name": [
199
- "Normal",
200
- "Romanized"
201
- ],
202
- "check_in": "output",
203
- "rules": [
204
- {
205
- "type": "direct_replace",
206
- "check_in": "output",
207
- "to_replace": [
208
- [
209
- 48
210
- ]
211
- ],
212
- "replace_with": [
213
- 1
214
- ]
215
- }
216
- ]
217
- }
218
- };
219
-
220
- export default _default;
@@ -1,100 +0,0 @@
1
- import { CustomOptionType } from './transliteration/transliterate';
2
- import { script_input_name_type } from './utils/lang_list/script_normalization';
3
- import { SCRIPT_LIST, LANG_LIST, ALL_LANG_SCRIPT_LIST, script_list_type, lang_list_type, script_and_lang_list_type } from './utils/lang_list';
4
- export {
5
- /**
6
- * The list of all supported script names
7
- */
8
- SCRIPT_LIST,
9
- /**
10
- * The list of all supported language names which are mapped to a script
11
- */
12
- LANG_LIST,
13
- /** Lists of all Supported Script/Language */
14
- ALL_LANG_SCRIPT_LIST };
15
- /** Type of the script list */
16
- export type ScriptListType = script_list_type;
17
- /** Type of the language list */
18
- export type LangListType = lang_list_type;
19
- /** Type of the script and language list */
20
- export type ScriptAndLangListType = script_and_lang_list_type;
21
- /**
22
- * Preloads the script data. Useful for browsers as avoids the fetch latency
23
- * @param name - The name of the script/language to preload
24
- * @returns The script data
25
- * @public
26
- */
27
- export declare const preloadScriptData: (name: script_input_name_type) => Promise<import('./make_script_data/output_script_data_schema').OutputScriptData>;
28
- /**
29
- * Supported script/language identifier types
30
- */
31
- export type ScriptLangType = script_input_name_type;
32
- /**
33
- * Transliterates `text` from `from` to `to`.
34
- * @param text - The text to transliterate
35
- * @param from - The script/language to transliterate from
36
- * @param to - The script/language to transliterate to
37
- * @param options - The custom options to use for the transliteration
38
- * @returns The transliterated text
39
- */
40
- export declare function transliterate(text: string, from: ScriptLangType, to: ScriptLangType, options?: CustomOptionType): Promise<string>;
41
- /**
42
- * This returns the list of all supported custom options for
43
- * transliterations for the provided script pair
44
- * @param from_script_name - The script/language to transliterate from
45
- * @param to_script_name - The script/language to transliterate to
46
- * @returns The list of all supported custom options for the provided script pair
47
- */
48
- export declare function getAllOptions(from_script_name: ScriptLangType, to_script_name: ScriptLangType): Promise<("all_to_normal:replace_pancham_varga_varna_with_n" | "brahmic_to_brahmic:replace_pancham_varga_varna_with_anuvsvAra" | "all_to_sinhala:use_conjuct_enabling_halant" | "all_to_normal:remove_virAma_and_double_virAma" | "all_to_normal:replace_avagraha_with_a")[]>;
49
- /**
50
- * Custom Transliteration Options
51
- */
52
- export type TransliterationOptions = CustomOptionType;
53
- /**
54
- * Creates a stateful isolated context for character by character input typing.
55
- * This is the main function which returns the `diff`, different realtime schems can be implemented using this.
56
- *
57
- * **Note** :- Script Data is loaded in background but it would still be good to await `ready` before using the context.
58
- * @param typing_lang - The script/language to type in
59
- * @returns A closed over context object with the following methods:
60
- */
61
- export declare function createTypingContext(typing_lang: ScriptLangType): {
62
- /** Await once, then use `takeKeyInputSync` for best typing latency. */
63
- ready: Promise<void>;
64
- clearContext: () => void;
65
- takeKeyInput: (key: string) => {
66
- /** These number of characters need to be deleted from the current "app" input state */
67
- to_delete_chars_count: number;
68
- /** These characters need to be added to the current "app" input state */
69
- diff_add_text: string;
70
- };
71
- getCurrentOutput: () => string;
72
- };
73
- type TextInputElement = HTMLInputElement | HTMLTextAreaElement;
74
- /**
75
- * Cross-framework event type for `<input>` / `<textarea>` handlers.
76
- *
77
- * - Svelte / Solid / Vue typically pass the native DOM event (`InputEvent` at runtime).
78
- * - React wraps DOM events in a SyntheticEvent which exposes the original via `nativeEvent`.
79
- */
80
- export type TextInputEvent = (Event & {
81
- currentTarget: TextInputElement;
82
- }) | {
83
- currentTarget: TextInputElement;
84
- nativeEvent: Event;
85
- };
86
- /**
87
- * Handles input events for transliteration typing in `input` and `textarea` elements
88
- *
89
- * @param typingContext - The typing context created for the element
90
- * @param event - Input Event
91
- * @param onValueChange - Optional callback function invoked when the value changes
92
- */
93
- export declare function handleTypingInputEvent(typingContext: ReturnType<typeof createTypingContext>, event: TextInputEvent, onValueChange?: (updatedValue: string) => void): Promise<void>;
94
- /**
95
- * Checks if the keydown event should clear the typing context
96
- * @param e - The keydown event
97
- * @param ctx - The typing context
98
- * @returns True if the keydown event should clear the typing context, false otherwise
99
- */
100
- export declare function clearTypingContextOnKeyDown(e: KeyboardEvent, ctx: ReturnType<typeof createTypingContext>): boolean;
@@ -1,62 +0,0 @@
1
- import { script_list_type } from '../utils/lang_list';
2
- import { KramaKeysExtendedType } from './krama_array_keys';
3
- type ReplacePrevKramaKeysRule = {
4
- /** in this we check if the string prev_krama_keys combines string appears before any one of the following_krama_keys */
5
- type: 'replace_prev_krama_keys';
6
- prev: KramaKeysExtendedType[];
7
- following: KramaKeysExtendedType[];
8
- /** will be combined to a single string */
9
- replace_with: KramaKeysExtendedType[];
10
- };
11
- type DirectReplaceRule = {
12
- type: 'direct_replace';
13
- /** set of individual krama key combinations to replace */
14
- to_replace: KramaKeysExtendedType[][];
15
- replace_with: (KramaKeysExtendedType | null)[];
16
- /** If this is present it will take precedence over the replace_with array.
17
- * Text here will be directly without any krama mappings
18
- */
19
- replace_text?: string;
20
- };
21
- type CommonRuleTypeAttributes = {
22
- /** Specifies if the pattern has to checked in input or output text */
23
- check_in: 'input' | 'output';
24
- /** Use `replaceAll` to directly replace the pattern with the replace_with string
25
- *
26
- * **Note** :- Avoid using this pattern as much as possible it can be slower for large inputs
27
- *
28
- * When the `check_in` is `input` then we replace before the process and
29
- * when it is `output` then we replace after the process.
30
- *
31
- * Always fall back to `use_replace` only when implementation becomes too complex or otherwise.
32
- * The *Aim* should be to develop techniques so we dont have to rely on it too much.
33
- */
34
- use_replace?: boolean;
35
- };
36
- type InputRuleTypes = Omit<CommonRuleTypeAttributes, 'check_in'> & {
37
- check_in?: CommonRuleTypeAttributes['check_in'];
38
- } & (ReplacePrevKramaKeysRule | DirectReplaceRule);
39
- type CustomOptionsRecordType = {
40
- from_script_name?: script_list_type[];
41
- from_script_type?: 'brahmic' | 'other' | 'all';
42
- to_script_name?: script_list_type[];
43
- to_script_type?: 'brahmic' | 'other' | 'all';
44
- rules: InputRuleTypes[];
45
- } & CommonRuleTypeAttributes;
46
- type InputCustomOptionsType = Record<`${string}:${string}`, CustomOptionsRecordType>;
47
- type out_ReplacePrevKramaKeysRule = Pick<ReplacePrevKramaKeysRule, 'type'> & {
48
- prev: number[];
49
- following: number[];
50
- replace_with: number[];
51
- };
52
- type out_DirectReplaceRule = Pick<DirectReplaceRule, 'type'> & {
53
- to_replace: number[][];
54
- replace_with: number[];
55
- replace_text?: string;
56
- };
57
- /** This is final type that will be actually used by the transliterator */
58
- export type OptionsType = Record<`${string}:${string}`, Omit<CustomOptionsRecordType, 'rules'> & {
59
- rules: (CommonRuleTypeAttributes & (out_ReplacePrevKramaKeysRule | out_DirectReplaceRule))[];
60
- }>;
61
- export declare const CustomOptionsInput: InputCustomOptionsType;
62
- export {};
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Assamese: InputBrahmicScriptType;
3
- export default Assamese;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Bengali: InputBrahmicScriptType;
3
- export default Bengali;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Brahmi: InputBrahmicScriptType;
3
- export default Brahmi;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Devanagari: InputBrahmicScriptType;
3
- export default Devanagari;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Granth: InputBrahmicScriptType;
3
- export default Granth;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Gujarati: InputBrahmicScriptType;
3
- export default Gujarati;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Gurumukhi: InputBrahmicScriptType;
3
- export default Gurumukhi;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Kannada: InputBrahmicScriptType;
3
- export default Kannada;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Malayalam: InputBrahmicScriptType;
3
- export default Malayalam;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Modi: InputBrahmicScriptType;
3
- export default Modi;
@@ -1,3 +0,0 @@
1
- import { InputOtherScriptType } from '../input_script_data_schema';
2
- declare const Normal: InputOtherScriptType;
3
- export default Normal;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Odia: InputBrahmicScriptType;
3
- export default Odia;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Purna_Devanagari: InputBrahmicScriptType;
3
- export default Purna_Devanagari;
@@ -1,3 +0,0 @@
1
- import { InputOtherScriptType } from '../input_script_data_schema';
2
- declare const Romanized: InputOtherScriptType;
3
- export default Romanized;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Sharada: InputBrahmicScriptType;
3
- export default Sharada;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Siddham: InputBrahmicScriptType;
3
- export default Siddham;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Sinhala: InputBrahmicScriptType;
3
- export default Sinhala;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Tamil_Extended: InputBrahmicScriptType;
3
- export default Tamil_Extended;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Tamil: InputBrahmicScriptType;
3
- export default Tamil;
@@ -1,3 +0,0 @@
1
- import { InputBrahmicScriptType } from '../input_script_data_schema';
2
- declare const Telugu: InputBrahmicScriptType;
3
- export default Telugu;
@@ -1,91 +0,0 @@
1
- import { KramaKeysExtendedType } from './krama_array_keys';
2
- import { script_list_type } from '../utils/lang_list';
3
- export type CommonListTypeAttributes = {
4
- text: string;
5
- /** In the post processing step the keys for which it is not mapped shall be left empty.
6
- * It can map to multiple krama keys
7
- * Each key should have at least one key krama. Scan for this too in the compilation step.
8
- */
9
- text_krama: KramaKeysExtendedType[];
10
- /** This contains duplicates of the key, for eg:- some nuqta symbols and mAtrAs.
11
- * In the processing/compiling step it should be verified as a key of this list, display and throw the error
12
- */
13
- duplicates?: string[];
14
- /** In case if no entry is found for the key in krama even after de-duplication resolution
15
- * then fallback array will be used. Like for malayalam .100 it can be .1+.0+.0
16
- * If the fallback array is not provided, then the key_krama should be empty and will also be ignored
17
- */
18
- fallback?: KramaKeysExtendedType[];
19
- /** Prevent Auto Matching
20
- * Useful for Cases where we dont want to use the text referenced in the key to be used for transliteration from that script to another script
21
- * Like when changing from Tamil to Devanagari , kirupA it should be kirupA and not kRpA.
22
- * So we can prevent the list item "text": iru, krama R) from being used to reduce itself from that form during transliteration
23
- */
24
- prevent_auto_matching?: boolean;
25
- };
26
- export type InputBrahmicScriptType = {
27
- script_name: script_list_type;
28
- script_id: number;
29
- script_type: 'brahmic';
30
- /**
31
- * An attribute for some ancient scripts which use 4 byte utf-8 representation.
32
- * Instead of the usual 3 byte for most modern indian scripts.
33
- * Examples(non-bmp scripts): Brahmi, Grantha, Siddham, Sharada, Modi, etc.
34
- *
35
- * BMP (Basic Multilingual Plane)
36
- */
37
- non_bmp_script?: boolean;
38
- /**
39
- * A sorted range array. Used to check if the incomming character has to be processed or can be ignored.
40
- * Main Ranges will be specified manually (Like for a Brahmic Script). And Ranges for Additional charcters used shall be added manually
41
- *
42
- * This will help us more strictly specify what to process and what not to.
43
- * In future this will be a mandatory field and ?
44
- */
45
- ranges?: [[number, number][]];
46
- halant: string;
47
- nuqta?: string;
48
- /**
49
- * Schwa deletion indicator for the script(or rather language in most cases).
50
- * This will be used for live typing and not for conversion.
51
- * It can be overriden later on provided as a argument in the typing tool
52
- */
53
- schwa_property: boolean;
54
- /**
55
- * This has a lower precedence than the auto generated/compiled krama key map from the `list` items. So it will be overwritten by them.
56
- * Moreover the keys here will not be checked to exist in `list`. This allows direct keymaps and can be useful for scripts like Normal, Romanized
57
- * Intermediate steps will be auto generated. Eg. for Normal ख : kh will add both k (next h) and kh in the
58
- */
59
- manual_krama_text_map?: {
60
- [key in KramaKeysExtendedType]?: string;
61
- };
62
- /** One important need of this list is to just contain information about the keys.
63
- * The keys for which it does not contain information can be considered as type `anya`.
64
- * So not all keys need to be present in this list.
65
- */
66
- list: (CommonListTypeAttributes & ({
67
- type: 'svara';
68
- mAtrA: string;
69
- mAtrA_text_krama: KramaKeysExtendedType[];
70
- mAtrA_duplicates?: string[];
71
- mAtrA_fallback?: KramaKeysExtendedType[];
72
- } | {
73
- type: 'vyanjana' | 'anya';
74
- }))[];
75
- };
76
- export type InputOtherScriptType = {
77
- script_name: script_list_type;
78
- script_id: number;
79
- script_type: 'other';
80
- /** Schwa deletion character, usually `a` */
81
- schwa_character: string;
82
- manual_krama_text_map: {
83
- [key in KramaKeysExtendedType]?: string;
84
- };
85
- /** This might not be needed here usually as most of the work would be done using the `manual_krama_text_map` */
86
- list?: (CommonListTypeAttributes & {
87
- /** `type` is kind of redundant here as other scripts don't have a concept of svara and vyanjana */
88
- type?: 'anya';
89
- })[];
90
- };
91
- export type InputScriptInfoType = InputBrahmicScriptType | InputOtherScriptType;