@lantun/core 0.1.0 → 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/README.md +76 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,15 +1,87 @@
|
|
|
1
1
|
# @lantun/core
|
|
2
2
|
|
|
3
|
-
Read any article aloud, with each sentence and word highlighted, plus reading aids for low vision, dyslexia and ADHD
|
|
3
|
+
**Read any article aloud, with each sentence and word highlighted, plus reading aids for low vision, dyslexia and ADHD.**
|
|
4
|
+
|
|
5
|
+
Lantun adds a small dock to your page. Readers press play and hear the article while it highlights along. A second button opens reading aids: text size, spacing, dyslexia font, colour modes, reading guide and more. It finds the article by itself, runs entirely in the browser, and needs no backend or account.
|
|
6
|
+
|
|
7
|
+
**[Try the live demo →](https://lantun.rzknkbr.xyz)** Open any sample article and press play.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Install
|
|
4
12
|
|
|
5
13
|
```sh
|
|
6
|
-
npm install @lantun/core
|
|
14
|
+
npm install @lantun/core @lantun/voice-kitten
|
|
7
15
|
```
|
|
8
16
|
|
|
17
|
+
`@lantun/voice-kitten` is optional but recommended. Browser voices differ by device and often sound robotic. The Kitten voices sound natural everywhere, run on the reader's device, and download nothing until a reader picks one.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
9
21
|
```ts
|
|
10
|
-
import { init } from "@lantun/core";
|
|
22
|
+
import { init, registerVoices } from "@lantun/core";
|
|
23
|
+
import { kittenVoices } from "@lantun/voice-kitten";
|
|
11
24
|
|
|
25
|
+
registerVoices(kittenVoices());
|
|
12
26
|
init({ contentSelector: "article", color: "#7c3aed" });
|
|
13
27
|
```
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
Call `init()` once the article is in the DOM. With no options, Lantun detects the article itself and skips menus, ads, captions, code blocks and "Read also" links. In a single-page app it notices when the article changes and reads the new one.
|
|
30
|
+
|
|
31
|
+
## Options
|
|
32
|
+
|
|
33
|
+
All options are optional.
|
|
34
|
+
|
|
35
|
+
| Option | Default | What it does |
|
|
36
|
+
| ------------------ | --------------------------- | ------------------------------------------------------- |
|
|
37
|
+
| `contentSelector` | auto-detected | Where the article body is. |
|
|
38
|
+
| `excludeSelectors` | `[]` | Selectors that are never read aloud. |
|
|
39
|
+
| `position` | `"right"` | Dock side: `"right"` or `"left"`. |
|
|
40
|
+
| `color` | `"#f5b841"` | Highlight and accent colour; any CSS colour. |
|
|
41
|
+
| `lang` | `<html lang>`, then `en` | Article language; picks the voices and the UI language. |
|
|
42
|
+
| `features` | `{ tts: true, a11y: true }` | Turn listening or reading aids off. |
|
|
43
|
+
| `zIndex` | `2147483000` | Stacking order of the dock. |
|
|
44
|
+
| `nonce` | none | CSP nonce for Lantun's `<style>` elements. |
|
|
45
|
+
|
|
46
|
+
To skip one element without a selector, add `data-reader-skip` to it.
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
| Function | Description |
|
|
51
|
+
| ------------------------ | ---------------------------------------------------------------------------- |
|
|
52
|
+
| `init(options?)` | Starts the widget. |
|
|
53
|
+
| `destroy()` | Removes everything Lantun added to the page. |
|
|
54
|
+
| `play()` / `pause()` | Controls playback. Browsers allow `play()` only after a user interaction. |
|
|
55
|
+
| `on(event, handler)` | Listens to `sentence`, `word`, `end` or `error`, and returns an unsubscribe. |
|
|
56
|
+
| `registerVoices(engine)` | Adds an add-on voice engine, such as `kittenVoices()`. |
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { on } from "@lantun/core";
|
|
60
|
+
|
|
61
|
+
const off = on("end", () => console.log("Finished the article"));
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Turn on debug logs with `localStorage.setItem("lantun:debug", "1")`.
|
|
65
|
+
|
|
66
|
+
## Highlights
|
|
67
|
+
|
|
68
|
+
- **Follows along:** highlights the current sentence and word, and scrolls gently with them.
|
|
69
|
+
- **Starts anywhere:** hover a paragraph or select text, then press play.
|
|
70
|
+
- **Remembers:** returning readers continue from the same sentence.
|
|
71
|
+
- **Won't break your site:** the UI lives in a shadow root, survives hostile CSS and strict CSPs, and never throws into your page.
|
|
72
|
+
- **Light:** about 38 kB gzipped.
|
|
73
|
+
- **Accessible:** keyboard-operable, screen-reader friendly, checked with axe.
|
|
74
|
+
- **Bilingual UI:** English and Indonesian, from the page language.
|
|
75
|
+
|
|
76
|
+
## Other setups
|
|
77
|
+
|
|
78
|
+
- **No build step?** Use the [`lantun`](https://www.npmjs.com/package/lantun) script tag.
|
|
79
|
+
- **React or Next.js?** Use [`@lantun/react`](https://www.npmjs.com/package/@lantun/react).
|
|
80
|
+
|
|
81
|
+
## Links
|
|
82
|
+
|
|
83
|
+
- [Live demo](https://lantun.rzknkbr.xyz)
|
|
84
|
+
- [GitHub](https://github.com/rizkianakbar/lantun) (full docs and screenshots)
|
|
85
|
+
- [Issues](https://github.com/rizkianakbar/lantun/issues)
|
|
86
|
+
|
|
87
|
+
MIT licensed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lantun/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Read any article aloud with word highlighting, plus reading aids for low vision, dyslexia and ADHD. One script, no backend.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"text-to-speech",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"author": "rizkianakbar",
|
|
18
|
-
"homepage": "https://
|
|
18
|
+
"homepage": "https://lantun.rzknkbr.xyz",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "git+https://github.com/rizkianakbar/lantun.git",
|