|
3 | 3 | <img src="https://raw.githubusercontent.com/eoussama/eo-typewriterjs/refs/heads/master/assets/logo.svg" alt="Logo" width="200px"> |
4 | 4 | <h1 align="center">eo-typewriterjs</h1> |
5 | 5 | </a> |
6 | | - <p align="center">Advanced typewriter-style text animation utility for JavaScript, with timeline playback, cursor movement, selection, deletion, and renderer-agnostic text styling.</p> |
| 6 | + <p align="center">Build rich typewriter animations with a composable timeline, full Unicode support, and a renderer-agnostic architecture that works in the browser and on the server.</p> |
7 | 7 | <p align="center"> |
8 | 8 | <img src="https://img.shields.io/github/release/EOussama/typewriterjs.svg"> |
9 | 9 | <img src="https://img.shields.io/github/downloads/EOussama/typewriterjs/latest/total.svg"> |
|
20 | 20 | pnpm add eo-typewriterjs |
21 | 21 | ``` |
22 | 22 |
|
| 23 | +## Why eo-typewriterjs |
| 24 | + |
| 25 | +- **Composable timeline**: chain type, delete, wait, move, select, and call commands in any order |
| 26 | +- **Flexible advance modes**: type by character, word, line, grapheme, or custom chunk size |
| 27 | +- **Rich text support**: apply styles and marks to ranges during playback |
| 28 | +- **Full Unicode**: handles emoji, accented characters, and complex grapheme clusters correctly |
| 29 | +- **Renderer-agnostic**: built-in DOM and string renderers; implement `IRenderer` to target anything |
| 30 | +- **TypeScript-first**: fully typed public API with no `any` |
| 31 | +- **Playback controls**: play, pause, stop, replay, and cancel from any point |
| 32 | + |
23 | 33 | ## Quick start |
24 | 34 |
|
25 | 35 | ```ts |
26 | 36 | import { createTypewriter, domRenderer } from "eo-typewriterjs"; |
27 | 37 |
|
28 | 38 |
|
29 | 39 |
|
30 | | -const element = document.getElementById("output"); |
| 40 | +const el = document.getElementById("output")!; |
31 | 41 |
|
32 | | -if (element === null) { |
33 | | - throw new Error("Missing #output element"); |
34 | | -} |
35 | | - |
36 | | -const typewriter = createTypewriter({ |
37 | | - renderer: domRenderer(element), |
| 42 | +const tw = createTypewriter({ |
| 43 | + renderer: domRenderer(el), |
38 | 44 | }); |
39 | 45 |
|
40 | | -typewriter.timeline |
41 | | - .type("Hello ") |
42 | | - .type("world!", { style: "accent" }) |
43 | | - .mark("highlight", { from: 6, to: 12 }); |
| 46 | +tw.timeline |
| 47 | + .type("Hello, ") |
| 48 | + .type("world!", { by: "word", interval: 120 }) |
| 49 | + .wait(400) |
| 50 | + .delete({ amount: 6 }) |
| 51 | + .type("eo-typewriterjs.", { interval: 80 }); |
44 | 52 |
|
45 | | -await typewriter.play(); |
| 53 | +await tw.play(); |
46 | 54 | ``` |
47 | 55 |
|
48 | | -## Common commands |
| 56 | +## Documentation |
49 | 57 |
|
50 | | -```bash |
51 | | -pnpm dev |
52 | | -pnpm build |
53 | | -pnpm test |
54 | | -pnpm lint |
55 | | -pnpm sandbox |
56 | | -pnpm docs:dev |
57 | | -pnpm docs:build |
58 | | -``` |
| 58 | +Full documentation, guides, and the API reference are available on the docs site. |
59 | 59 |
|
60 | | -## Documentation |
| 60 | +- [Docs site](https://ouss.es/eo-typewriterjs/) |
| 61 | +- [Getting started](https://ouss.es/eo-typewriterjs/guide/getting-started) |
| 62 | +- [Core concepts](https://ouss.es/eo-typewriterjs/guide/core-concepts) |
| 63 | +- [Timeline](https://ouss.es/eo-typewriterjs/guide/timeline) |
| 64 | +- [Renderers](https://ouss.es/eo-typewriterjs/guide/renderers) |
| 65 | +- [Recipes](https://ouss.es/eo-typewriterjs/guide/recipes) |
| 66 | +- [API reference](https://ouss.es/eo-typewriterjs/api/) |
61 | 67 |
|
62 | | -Full documentation is available at the [docs site](https://eoussama.github.io/eo-typewriterjs/). |
| 68 | +## Sandbox |
63 | 69 |
|
64 | | -- [Getting Started](https://eoussama.github.io/eo-typewriterjs/guide/getting-started) |
65 | | -- [Core Concepts](https://eoussama.github.io/eo-typewriterjs/guide/core-concepts) |
66 | | -- [Timeline & Commands](https://eoussama.github.io/eo-typewriterjs/guide/timeline) |
67 | | -- [Renderers](https://eoussama.github.io/eo-typewriterjs/guide/renderers) |
68 | | -- [Recipes](https://eoussama.github.io/eo-typewriterjs/guide/recipes) |
69 | | -- [API Reference](https://eoussama.github.io/eo-typewriterjs/api/) |
| 70 | +Try the library live in the interactive [sandbox](https://ouss.es/eo-typewriterjs/sandbox/), write timelines, run them, and see output in real time without any setup. |
| 71 | + |
| 72 | +## Testing |
| 73 | + |
| 74 | +The library is covered by two test layers: |
| 75 | + |
| 76 | +- **Unit tests** (`pnpm test`): Vitest suite covering core logic, reducers, renderers, and edge cases. |
| 77 | +- **End-to-end tests** (`pnpm e2e`): Playwright suite running real playback scenarios in a browser harness, including typing flows, waiting, multiline output, cursor movement, selection, editing, and callbacks. |
| 78 | + |
| 79 | +## Development |
| 80 | + |
| 81 | +```bash |
| 82 | +pnpm dev # start dev server |
| 83 | +pnpm build # build the library |
| 84 | +pnpm test # run unit tests |
| 85 | +pnpm e2e # run end-to-end tests |
| 86 | +pnpm lint # lint |
| 87 | +pnpm sandbox # start the sandbox |
| 88 | +pnpm docs:dev # start the docs site |
| 89 | +``` |
70 | 90 |
|
71 | 91 | ## License |
72 | 92 |
|
|
0 commit comments