|
| 1 | +# Bengali CLI, npm/WASM and browser integration |
| 2 | + |
| 3 | +T-0069 exposes the existing Bengali engine through CLI language selection; |
| 4 | +T-0070 adds the same choice to npm/WASM and the browser. Neither increment |
| 5 | +changes the core rules, learned artifacts or quality thresholds. Bengali |
| 6 | +remains experimental; the independent lyrics-reference review is still open. |
| 7 | + |
| 8 | +## Contract |
| 9 | + |
| 10 | +- CLI: `--language=bengali` and `--language bengali`; omitting the option selects |
| 11 | + Hindi. Selection applies to every input/debug/test/rule mode. Full language |
| 12 | + names are case-insensitive. Missing, empty and unsupported values fail. |
| 13 | +- JS: `translit(text, {language: "bengali"})`; each call independently defaults |
| 14 | + to Hindi when language is absent. Both ESM and CJS forward the option. Invalid |
| 15 | + values throw an Error without terminating the WASM runtime. The TypeScript |
| 16 | + `Language` union exposes the canonical lowercase names. |
| 17 | +- Browser: a labeled selector updates input language, label, placeholder, sample |
| 18 | + and rendered output. Existing text survives language changes. Checkbox values |
| 19 | + are remembered separately per language for the current page session. Hindi |
| 20 | + retains its previous Long vowels default; Bengali starts with all flags off. |
| 21 | +- Bengali reranking requires the vowel model. Hindi style toggles are hidden |
| 22 | + for Bengali: they do not implement Bengali rendering styles, and passing them |
| 23 | + through the API bypasses Bengali lexicon/reranking under the existing contract. |
| 24 | +- npm and web assets include code/embedded-data attribution via `NOTICE.md`. |
| 25 | + The package version is unchanged and no package or website is published. |
| 26 | + |
| 27 | +## Validation |
| 28 | + |
| 29 | +CLI subprocess tests run the actual entry point and compare both languages with |
| 30 | +the library. Coverage includes positional and piped input, input files, TSV |
| 31 | +comparison, debug, rule listing/overrides, omitted language and malformed flags. |
| 32 | +A sanity-revert to the hard-coded Hindi constructor fails the Bengali tests. |
| 33 | +Full local `make ci` passed for CLI commit `3e3665e` in an isolated checkout. |
| 34 | + |
| 35 | +`make npm-test` now builds the CLI as well as WASM. Both ESM and CJS test nine |
| 36 | +option profiles for each language against the CLI, plus defaults after Bengali |
| 37 | +calls, option reset, mixed scripts, whitespace/punctuation and recovery after |
| 38 | +invalid languages. A sanity-revert that ignores the WASM language option fails |
| 39 | +its Bengali assertion; the restored implementation passes. TypeScript strict |
| 40 | +checking accepts both languages and rejects an unsupported one. An npm pack |
| 41 | +dry run confirms the entry points, declarations, WASM, runtime and notice ship. |
| 42 | + |
| 43 | +Local Safari inspection confirms initial Hindi selection, successful Bengali |
| 44 | +sample rendering, text preservation during switching, restored Hindi defaults |
| 45 | +and remembered Bengali learned options. A final page check confirms that only |
| 46 | +supported learned controls appear for Bengali. The second full local `make ci` |
| 47 | +result is recorded in the npm/browser PR. Hosted full CI remains configured for |
| 48 | +main-targeting PRs, so these stacked-branch full runs are local. |
| 49 | + |
| 50 | +## Review notes (2026-10-05) |
| 51 | + |
| 52 | +Independent stack review; language/option isolation, ESM/CJS parity, textContent |
| 53 | +output and per-language UI state verified. |
| 54 | + |
| 55 | +- **Flag types are validated in JS.** Only `language` was type-checked, so a |
| 56 | + BigInt flag (`{longVowels: 1n}`) panicked inside the Go runtime and every later |
| 57 | + call failed with "Go program has already exited"; string flags were truthy |
| 58 | + (`"false"` meant true). Both wrappers now reject non-object options and |
| 59 | + non-boolean flags with `TypeError`; the smoke test asserts each case and that |
| 60 | + the instance survives. |
| 61 | +- **Licensing.** `NOTICE.md` lists every embedded data file (Hindi lexicon, schwa |
| 62 | + tree, n-grams; Bengali lexicon, vowel tree, selector) with source, license and |
| 63 | + changes. `package.json` declares `MIT AND CC-BY-SA-4.0 AND CC-BY-4.0`. GoReleaser |
| 64 | + archives now include `NOTICE.md`; the npm README links it absolutely. |
| 65 | +- **Web.** The language select opts out of browser form restoration so a restored |
| 66 | + value cannot desynchronize the UI; structured data lists `bn`. |
| 67 | +- Tracked: unknown option keys are ignored; npm Bengali `rerank` without |
| 68 | + `schwaModel` is silent (the CLI warns); the About dialog still describes the |
| 69 | + Hindi components only. |
0 commit comments