vyasa-sanskrit-wasm API Reference
vyasa-sanskrit-wasm is the WebAssembly facade crate in vyutils. It bundles vyasa-phonetics, vyasa-lipi, and vyasa-patha into a single, high-performance browser module distributed as the scoped npm package @project-vyasa/sanskrit-wasm.
Package Overview
Section titled “Package Overview”- NPM Package:
@project-vyasa/sanskrit-wasm - WASM Binary:
vyasa_sanskrit_wasm_bg.wasm(133 KB) - TypeScript Definitions: Fully typed declarations in
pkg/vyasa_sanskrit_wasm.d.ts - Target Environments: Modern Browsers (ESM), SvelteKit, Vite, Next.js, Electron, Node.js
TypeScript Interfaces (DTOs)
Section titled “TypeScript Interfaces (DTOs)”ScriptInfoDto
Section titled “ScriptInfoDto”export interface ScriptInfoDto { id: string; name: string; is_indic: boolean; has_vedic_pitch: boolean;}KramaStepDto
Section titled “KramaStepDto”export interface KramaStepDto { step_number: number; formula: string; first_index: number; second_index?: number; raw_pada: string; sandhied: string; is_parigraha: boolean; pragrhya_detected: boolean;}JataStepDto
Section titled “JataStepDto”export interface JataStepDto { step_number: number; formula: string; first_index: number; second_index?: number; forward_text: string; reverse_text: string; sandhied: string; is_parigraha: boolean;}GhanaStepDto
Section titled “GhanaStepDto”export interface GhanaStepDto { step_number: number; formula: string; first_index: number; second_index?: number; third_index?: number; forward_text: string; reverse_text: string; forward_triple: string; reverse_triple: string; sandhied: string; is_parigraha: boolean;}PadaInfoDto
Section titled “PadaInfoDto”export interface PadaInfoDto { raw: string; clean: string; compound_parts: string[]; is_compound: boolean; is_pragrhya: boolean; pragrhya_type?: string;}ShivaSutraDto
Section titled “ShivaSutraDto”export interface ShivaSutraDto { index: number; name: string; it_marker_deva: string; it_marker_iast: string; sounds_deva: string[]; sounds_iast: string[];}VarnaAnalysisDto
Section titled “VarnaAnalysisDto”export interface VarnaAnalysisDto { glyph_deva: string; glyph_iast: string; varna_type: 'vowel' | 'consonant' | 'ayogavaha'; sthana: string[]; abhyantara_prayatna: string; is_ghosha: boolean; is_alpaprana: boolean; matra: number;}AksharaAnalysisDto
Section titled “AksharaAnalysisDto”export interface AksharaAnalysisDto { surface: string; consonants: VarnaAnalysisDto[]; vowel?: VarnaAnalysisDto; ayogavaha?: string; svara?: string; total_matra: number;}Exported Functions
Section titled “Exported Functions”1. Transliteration & Scripts
Section titled “1. Transliteration & Scripts”transliterate(text: string, from_script: string, to_script: string): stringdetect_script(text: string): string | undefinedget_supported_scripts(): ScriptInfoDto[]
2. Vedic Recitation
Section titled “2. Vedic Recitation”generate_krama(input_pada_text: string, target_script: string): KramaStepDto[]generate_krama_text(input_pada_text: string, target_script: string): stringgenerate_jata(input_pada_text: string, target_script: string): JataStepDto[]generate_jata_text(input_pada_text: string, target_script: string): stringgenerate_ghana(input_pada_text: string, target_script: string): GhanaStepDto[]generate_ghana_text(input_pada_text: string, target_script: string): string- `parse_padas(input_pada_text: string): PadaInfoDto[]
3. Phonetics & Śiva Sūtras
Section titled “3. Phonetics & Śiva Sūtras”get_shiva_sutras(): ShivaSutraDto[]get_pratyahara_sounds(pratyahara_name: string): VarnaAnalysisDto[]check_pratyahara_contains(pratyahara_name: string, sound_symbol: string): booleaninspect_varna(varna_symbol: string): VarnaAnalysisDtoanalyze_syllables(text: string, script_name: string): AksharaAnalysisDto[]
Detailed Code Examples
Section titled “Detailed Code Examples”For comprehensive usage examples of every function, see the Sanskrit Developer Guide (Rust & WASM).