@lantun/react 0.0.0-stage → 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rizkianakbar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,64 @@
1
- # Temporary Holding Version
1
+ # @lantun/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **A read-aloud widget for React: text-to-speech with sentence and word highlighting, plus reading aids for low vision, dyslexia and ADHD.**
4
+
5
+ Drop `<LantunWidget />` on an article page. Readers get a small dock: press play to hear the article as it highlights along, or open the reading aids for text size, spacing, a dyslexia font, colour modes and more. It runs entirely in the browser, with no backend or account.
6
+
7
+ **[Try the live demo →](https://lantun.rzknkbr.xyz)** Open any sample article and press play.
8
+
9
+ ![Lantun reading an article aloud, highlighting the current sentence and word](https://raw.githubusercontent.com/rizkianakbar/lantun/main/docs/screenshots/playing.png)
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install @lantun/react @lantun/voice-kitten
15
+ ```
16
+
17
+ Requires React 17 or later. `@lantun/voice-kitten` is optional but recommended. Browser voices often sound robotic, while these natural voices run on the reader's device and download nothing until a reader picks one.
18
+
19
+ ## Usage
20
+
21
+ ```tsx
22
+ import { LantunWidget, registerVoices } from "@lantun/react";
23
+ import { kittenVoices } from "@lantun/voice-kitten";
24
+
25
+ registerVoices(kittenVoices());
26
+
27
+ export function ArticlePage() {
28
+ return (
29
+ <>
30
+ <article>…</article>
31
+ <LantunWidget contentSelector="article" color="#7c3aed" />
32
+ </>
33
+ );
34
+ }
35
+ ```
36
+
37
+ `<LantunWidget />` renders nothing in your tree. It starts the widget on mount, restarts it only when its props change, and removes it on unmount. It is safe under `StrictMode`. Render one per page.
38
+
39
+ ## Props
40
+
41
+ All props are optional.
42
+
43
+ | Prop | Default | What it does |
44
+ | ------------------ | --------------------------- | ------------------------------------------------------- |
45
+ | `contentSelector` | auto-detected | Where the article body is. |
46
+ | `excludeSelectors` | `[]` | Selectors that are never read aloud. |
47
+ | `position` | `"right"` | Dock side: `"right"` or `"left"`. |
48
+ | `color` | `"#f5b841"` | Highlight and accent colour; any CSS colour. |
49
+ | `lang` | `<html lang>`, then `en` | Article language; picks the voices and the UI language. |
50
+ | `features` | `{ tts: true, a11y: true }` | Turn listening or reading aids off. |
51
+ | `zIndex` | `2147483000` | Stacking order of the dock. |
52
+ | `nonce` | none | CSP nonce for Lantun's `<style>` elements. |
53
+
54
+ To skip one element without a selector, add `data-reader-skip` to it.
55
+
56
+ Need `play()`, `pause()` or events such as `on("end", …)`? Import them from [`@lantun/core`](https://www.npmjs.com/package/@lantun/core), which this package installs for you.
57
+
58
+ ## Links
59
+
60
+ - [Live demo](https://lantun.rzknkbr.xyz)
61
+ - [GitHub](https://github.com/rizkianakbar/lantun) (full docs and screenshots)
62
+ - [Issues](https://github.com/rizkianakbar/lantun/issues)
63
+
64
+ MIT licensed.
@@ -0,0 +1,4 @@
1
+ import { type ReaderOptions } from "@lantun/core";
2
+ export { registerVoices } from "@lantun/core";
3
+ export type LantunWidgetProps = ReaderOptions;
4
+ export declare function LantunWidget(props: LantunWidgetProps): null;
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { destroy, init } from "@lantun/core";
3
+ import { useEffect } from "react";
4
+ export { registerVoices } from "@lantun/core";
5
+ // Core is a page-level singleton, so the wrapper renders nothing and only owns its lifetime.
6
+ export function LantunWidget(props) {
7
+ const key = JSON.stringify(props);
8
+ // biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the serialised options, so equal props never re-init
9
+ useEffect(() => {
10
+ init(props);
11
+ return () => {
12
+ destroy();
13
+ };
14
+ }, [key]);
15
+ return null;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@lantun/react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Read-aloud widget for React and Next.js: text-to-speech with sentence and word highlighting, plus reading aids for low vision, dyslexia and ADHD.",
5
+ "keywords": [
6
+ "react",
7
+ "nextjs",
8
+ "text-to-speech",
9
+ "tts",
10
+ "read-aloud",
11
+ "accessibility",
12
+ "a11y",
13
+ "dyslexia",
14
+ "lantun"
15
+ ],
16
+ "license": "MIT",
17
+ "author": "rizkianakbar",
18
+ "homepage": "https://lantun.rzknkbr.xyz",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/rizkianakbar/lantun.git",
22
+ "directory": "packages/react"
23
+ },
24
+ "bugs": "https://github.com/rizkianakbar/lantun/issues",
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "dependencies": {
40
+ "@lantun/core": "^0.1.1"
41
+ },
42
+ "peerDependencies": {
43
+ "react": ">=17"
44
+ },
45
+ "devDependencies": {
46
+ "@types/react": "^19.3.0",
47
+ "@types/react-dom": "^19.3.0",
48
+ "jsdom": "^30.1.3",
49
+ "react": "^19.3.1",
50
+ "react-dom": "^19.3.1",
51
+ "typescript": "7.0.2",
52
+ "vitest": "^5.0.5"
53
+ },
54
+ "scripts": {
55
+ "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
56
+ "typecheck": "tsc --noEmit",
57
+ "test": "vitest run"
58
+ }
6
59
  }