lipic-js
v1.1.2
Published
lipic-js transliteration building blocks (data-first)
Maintainers
Readme
lipic-js
Fast transliteration for web text inputs (input, textarea, contenteditable) with a JS/WASM hybrid runtime.
Playground • Issues • Discussions
Table of Contents
- Features
- Quick Start
- Supported Languages
- Usage Options
- Configuration
- Mobile Keyboard Notes
- Build Options
- Development
- Contributing
- License
Features
- Easy integration: Works with
input,textarea, andcontenteditableelements - High performance: Hybrid JavaScript/WebAssembly runtime
- Multi-language support: 27 Indian and South Asian languages across major scripts
- Flexible installation: npm, CDN, or self-hosted
- Type-safe: First-class TypeScript support
Quick Start
Installation
npm install lipic-jsFrom GitHub (optional):
npm install github:ranjeet-h/lipic-jsBasic Usage
import { enableTransliteration } from "lipic-js";
// Enable transliteration for Hindi
const session = await enableTransliteration({
language: "hi",
selector: "input[type='text'], textarea, [contenteditable='true']"
});
// Later, when you want to disable
session.detach();Supported Languages
Total supported languages: 27
| Script | Languages |
|--------|-----------|
| Devanagari | hi (Hindi), mr (Marathi), ne (Nepali), sa (Sanskrit), kok (Konkani), mai (Maithili), doi (Dogri), brx (Bodo), sd (Sindhi), hne (Chhattisgarhi), bho (Bhojpuri), raj (Rajasthani), awa (Awadhi) |
| Bengali | bn (Bengali), as (Assamese) |
| Gujarati | gu (Gujarati) |
| Gurmukhi | pa (Punjabi) |
| Tamil | ta (Tamil) |
| Telugu | te (Telugu) |
| Kannada | kn (Kannada) |
| Malayalam | ml (Malayalam) |
| Odia | or (Odia) |
| Meitei Mayek | mni (Manipuri) |
| Ol Chiki | sat (Santali) |
| Perso-Arabic | ur (Urdu), ks (Kashmiri) |
| Sinhala | si (Sinhala) |
Implementation Status
Currently Available (27): hi, mr, ne, sa, bn, as, gu, pa, ta, te, kn, ml, or, kok, mai, doi, brx, sd, hne, bho, raj, awa, mni, sat, ur, ks, si
Usage Options
1. npm Package
npm install lipic-jsimport { enableTransliteration } from "lipic-js";
const session = await enableTransliteration({
language: "hi",
engineFactoryOptions: { isWasm: "auto" }
});2. CDN (Script Tag)
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/lipic-js.iife.min.js"></script>
<script>
// API is exposed as window.LipicJS
(async () => {
const session = await window.LipicJS.enableTransliteration({
language: "hi",
engineFactoryOptions: { isWasm: "auto" }
});
window._lipicSession = session;
})();
</script>3. Self-Hosted
After npm run build:all, copy dist/ to your server:
<script type="module">
import { enableTransliteration } from "/assets/lipic-js/index.js";
const session = await enableTransliteration({
language: "hi",
engineFactoryOptions: { isWasm: "auto" }
});
</script>Required files for direct hosting:
/assets/lipic-js/index.js(or cjs/iife variant)/assets/lipic-js/wasm/rust_core.js/assets/lipic-js/wasm/rust_core_bg.wasm
Configuration
createHybridTransliterationEngine and enableTransliteration support:
isWasm: "auto"(default): Use JS for keystrokes and WASM for batch processing when availableisWasm: true: Prefer WASM strongly (falls back to JS if WASM files are missing)isWasm: false: Force JS
If dist/wasm files are not present, the library continues with the JavaScript engine without breaking.
Mobile Keyboard Notes
Android/iOS keyboards (for example Samsung Keyboard, SwiftKey, Gboard) may emit composition/replacement input events instead of plain key events. lipic-js now handles these core event paths in the interceptor, but host setup still matters.
Recommended host setup for input, textarea, and contenteditable:
<input
type="text"
autocorrect="off"
autocapitalize="none"
autocomplete="off"
spellcheck="false"
inputmode="text"
/>Guidelines:
- Prefer
createInputInterceptor/enableTransliterationinstead of custom keydown-only handlers. - Track composition via
compositionstart/compositionendif you build custom integration. - Expect mobile IME paths such as
insertReplacementText,insertFromComposition, andinsertCompositionText. - Hard-refresh after upgrades so clients load the latest
distbundle.
Reference implementation:
playground/main.jsplayground/index.html
Build Options
npm run build:js-onlynpm run build:with-wasmArtifacts:
dist/dist/wasm/rust_core.jsdist/wasm/rust_core_bg.wasm
Development
- Node.js 18+
- Rust (optional, only for WebAssembly builds)
npm run build
npm run build:with-wasm
npm run test
npm run typecheck
npm run generate-map:all-languagesMapping tables are derived from:
npm run generate-map:all-languagesContributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Development Setup
git clone https://github.com/ranjeet-h/lipic-js.git
cd lipic-js
npm install
npm run build
npm testLicense
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
@indic-transliteration/common_mapsfor comprehensive transliteration mappings- The WebAssembly team for the amazing performance capabilities
- All contributors and users of this library
