npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dnsam/sinhala-phonetics

v0.1.1

Published

Sinhala phonetic input with word predictions — React components + headless converter

Readme

@dnsam/sinhala-phonetics

Type Sinhala phonetically. Get Unicode. Instantly.

A fully TypeScript-supported npm package for Sinhala phonetic input — ships React components with real-time conversion, word prediction, and full Tailwind CSS support.

npm install @dnsam/sinhala-phonetics

Features

  • Real-time conversion — type ayubowan, get ආයුබෝවන්
  • Word prediction — dropdown suggestions as you type, powered by a built-in Sinhala dictionary
  • React-ready — drop-in <SinhalaTypewriter> component with suggestion dropdown
  • Tailwind styled — default styles included; fully overridable via className props
  • Headless option — pass unstyled to get bare elements and style your own way
  • Framework-agnostic core — use convertText() and SinhalaPredictor anywhere (Node, browser, Svelte, Vue…)
  • Dual ESM + CJS — tree-shakeable, works in all modern bundlers
  • Zero runtime dependencies

Quick Start

All-in-one component (recommended)

import { SinhalaTypewriter } from '@dnsam/sinhala-phonetics';

export default function App() {
  const [text, setText] = useState('');

  return (
    <SinhalaTypewriter
      onChange={setText}
      placeholder='Type "ayubowan"…'
      maxSuggestions={5}
    />
  );
}

Tailwind content path

Add this to your tailwind.config.js so the default styles are not purged:

content: [
  // ... your other paths
  './node_modules/@dnsam/sinhala-phonetics/dist/**/*.js',
]

Phonetic Reference

| Type | You get | Meaning | |-----------|-----------|----------------| | ayubowan| ආයුබෝවන් | Hello / Welcome | | mama | මම | I / Me | | amma | අම්මා | Mother | | kohomada| කොහොමද | How are you? | | rata | රට | Country | | gama | ගම | Village | | aadare | ආදරේ | Love | | isthuthi| ඉස්තූති | Thanks |

Full phonetic mapping: see the converter source.


API Reference

<SinhalaTypewriter> — all-in-one component

<SinhalaTypewriter
  value={string}                   // controlled value (Sinhala)
  defaultValue={string}            // uncontrolled initial value
  onChange={(sinhala) => void}     // fires with converted Sinhala text
  onPhoneticChange={(raw) => void} // fires with raw phonetic input
  onSuggestionSelect={(word) => void}
  showSuggestions={true}           // default: true
  maxSuggestions={5}               // default: 5
  placeholder={string}
  disabled={boolean}
  rows={number}                    // default: 4
  unstyled={boolean}               // strip all default styles

  // className overrides
  className={string}               // wrapper div
  inputClassName={string}          // textarea
  suggestionsClassName={string}    // dropdown list <ul>
  suggestionItemClassName={string} // each <li>
/>

<SinhalaInput> — textarea only (no suggestions)

<SinhalaInput
  onChange={(sinhala) => void}
  placeholder="Type here…"
  rows={6}
/>

<SuggestionList> — standalone suggestion dropdown

<SuggestionList
  suggestions={[{ word: 'ගෙදර' }, { word: 'ගෙනාවා' }]}
  onSelect={(word) => console.log(word)}
/>

Hooks

useSinhalaConverter

Manages the phonetic ↔ Sinhala state. Useful when building a custom UI.

import { useSinhalaConverter } from '@dnsam/sinhala-phonetics';

const {
  phoneticValue,       // raw typed input
  sinhalaValue,        // converted Sinhala text
  currentWordPhonetic, // phonetic text of the word being typed
  currentWordSinhala,  // Sinhala conversion of current word
  handlePhoneticChange,// call this with textarea value on onChange
  replaceCurrentWord,  // inject a word, replaces current partial word
  reset,               // clear everything
} = useSinhalaConverter('', (sinhala) => console.log(sinhala));

useWordPrediction

import { useWordPrediction } from '@dnsam/sinhala-phonetics';

const suggestions = useWordPrediction(currentWordSinhala, {
  maxSuggestions: 5,
  predictor: myCustomPredictor, // optional, defaults to built-in
});
// suggestions: Array<{ word: string }>

Core Utilities

convertText(input: string): string

Framework-agnostic converter. Works in Node, Deno, browsers — anywhere.

import { convertText } from '@dnsam/sinhala-phonetics';

convertText('mama')      // → 'මම'
convertText('ayubowan') // → 'ආයුබෝවන්'
convertText('kohomada') // → 'කොහොමද'

SinhalaPredictor

Build your own predictor with a custom word list.

import { SinhalaPredictor } from '@dnsam/sinhala-phonetics';

const predictor = new SinhalaPredictor(['ගෙදර', 'ගෙනාවා', 'ගෙල']);
predictor.addWords(['අම්මා', 'තාත්තා']);

predictor.predict('ගෙ', 3);
// → [{ word: 'ගෙදර' }, { word: 'ගෙනාවා' }, { word: 'ගෙල' }]

SINHALA_WORDS

The built-in dictionary (~350 common words) as a plain string[]. Import it to extend or inspect.

import { SINHALA_WORDS } from '@dnsam/sinhala-phonetics';

TypeScript Types

import type {
  WordSuggestion,        // { word: string; frequency?: number }
  SinhalaInputProps,
  SinhalaTypewriterProps,
  SuggestionListProps,
} from '@dnsam/sinhala-phonetics';

Unstyled / Headless Usage

Pass unstyled to remove all default Tailwind classes and style entirely yourself:

<SinhalaTypewriter
  unstyled
  inputClassName="my-textarea-class"
  suggestionsClassName="my-dropdown-class"
  suggestionItemClassName="my-item-class"
  onChange={setText}
/>

Roadmap

  • [ ] Keyboard navigation for suggestions (↑ ↓ Enter)
  • [ ] Larger curated word dictionary
  • [ ] Frequency-based suggestion ranking
  • [ ] <SinhalaInlineInput> (single-line <input>)
  • [ ] Svelte / Vue wrappers

License

MIT © Dileepa Sam