Skip to content
This repository was archived by the owner on Jun 25, 2026. It is now read-only.

Commit 4090e81

Browse files
committed
docs: rename commands and update API references for v2 surface
Renames `moveCursor` to `move`, `clearSelection` to `unselect`, `mark`/`unmark` to `style`/`unstyle`, and updates all related types, docs, sidebar nav, and README examples to match the new command names. Also adds `AudioManagerHelper` to the API sidebar and simplifies the `delete` call signature in the quick start example.
1 parent d686847 commit 4090e81

66 files changed

Lines changed: 876 additions & 872 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ pnpm add eo-typewriterjs
2222

2323
## Why eo-typewriterjs
2424

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
25+
- **Composable timeline**: chain type, delete, wait, move, select, unselect, style, unstyle, 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 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.
3232

3333
## Quick start
3434

@@ -47,8 +47,8 @@ tw.timeline
4747
.type("Hello, ")
4848
.type("world!", { by: "word", interval: 120 })
4949
.wait(400)
50-
.delete({ amount: 6 })
51-
.type("eo-typewriterjs.", { interval: 80 });
50+
.delete(6)
51+
.type("EO TypewriterJS.");
5252

5353
await tw.play();
5454
```

docs/.vitepress/config.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export default defineConfig({
6565
{ text: "type", link: "/guide/commands/type" },
6666
{ text: "wait", link: "/guide/commands/wait" },
6767
{ text: "delete", link: "/guide/commands/delete" },
68-
{ text: "moveCursor", link: "/guide/commands/move-cursor" },
68+
{ text: "move", link: "/guide/commands/move" },
6969
{ text: "select", link: "/guide/commands/select" },
70-
{ text: "clearSelection", link: "/guide/commands/clear-selection" },
71-
{ text: "mark", link: "/guide/commands/mark" },
72-
{ text: "unmark", link: "/guide/commands/unmark" },
70+
{ text: "unselect", link: "/guide/commands/unselect" },
71+
{ text: "style", link: "/guide/commands/style" },
72+
{ text: "unstyle", link: "/guide/commands/unstyle" },
7373
{ text: "call", link: "/guide/commands/call" },
7474
],
7575
},
@@ -87,6 +87,10 @@ export default defineConfig({
8787
text: "Timeline",
8888
items: [{ text: "TimelineBuilder", link: "/api/classes/TimelineBuilder" }],
8989
},
90+
{
91+
text: "Audio",
92+
items: [{ text: "AudioManagerHelper", link: "/api/classes/AudioManagerHelper" }],
93+
},
9094
{
9195
text: "Renderers",
9296
items: [
@@ -132,17 +136,17 @@ export default defineConfig({
132136
{ text: "TAdvanceUnit", link: "/api/type-aliases/TAdvanceUnit" },
133137
{ text: "TDeleteCommand", link: "/api/type-aliases/TDeleteCommand" },
134138
{ text: "TDeleteOptions", link: "/api/type-aliases/TDeleteOptions" },
135-
{ text: "TMoveCursorCommand", link: "/api/type-aliases/TMoveCursorCommand" },
136-
{ text: "TMoveCursorOptions", link: "/api/type-aliases/TMoveCursorOptions" },
139+
{ text: "TMoveCommand", link: "/api/type-aliases/TMoveCommand" },
140+
{ text: "TMoveOptions", link: "/api/type-aliases/TMoveOptions" },
137141
{ text: "TSelectCommand", link: "/api/type-aliases/TSelectCommand" },
138142
{ text: "TSelectOptions", link: "/api/type-aliases/TSelectOptions" },
139-
{ text: "TClearSelectionCommand", link: "/api/type-aliases/TClearSelectionCommand" },
140-
{ text: "TClearSelectionOptions", link: "/api/type-aliases/TClearSelectionOptions" },
141-
{ text: "TMarkCommand", link: "/api/type-aliases/TMarkCommand" },
142-
{ text: "TMarkOptions", link: "/api/type-aliases/TMarkOptions" },
143-
{ text: "TMarkRange", link: "/api/type-aliases/TMarkRange" },
144-
{ text: "TUnmarkCommand", link: "/api/type-aliases/TUnmarkCommand" },
145-
{ text: "TUnmarkOptions", link: "/api/type-aliases/TUnmarkOptions" },
143+
{ text: "TUnselectCommand", link: "/api/type-aliases/TUnselectCommand" },
144+
{ text: "TUnselectOptions", link: "/api/type-aliases/TUnselectOptions" },
145+
{ text: "TStyleCommand", link: "/api/type-aliases/TStyleCommand" },
146+
{ text: "TStyleOptions", link: "/api/type-aliases/TStyleOptions" },
147+
{ text: "TStyleRange", link: "/api/type-aliases/TStyleRange" },
148+
{ text: "TUnstyleCommand", link: "/api/type-aliases/TUnstyleCommand" },
149+
{ text: "TUnstyleOptions", link: "/api/type-aliases/TUnstyleOptions" },
146150
{ text: "TCallCommand", link: "/api/type-aliases/TCallCommand" },
147151
{ text: "TCallbackFn", link: "/api/type-aliases/TCallbackFn" },
148152
{ text: "TCallbackContext", link: "/api/type-aliases/TCallbackContext" },
@@ -160,11 +164,11 @@ export default defineConfig({
160164
{ text: "TEventKind", link: "/api/type-aliases/TEventKind" },
161165
{ text: "TInsertEvent", link: "/api/type-aliases/TInsertEvent" },
162166
{ text: "TDeleteEvent", link: "/api/type-aliases/TDeleteEvent" },
163-
{ text: "TMoveCursorEvent", link: "/api/type-aliases/TMoveCursorEvent" },
167+
{ text: "TMoveEvent", link: "/api/type-aliases/TMoveEvent" },
164168
{ text: "TSelectEvent", link: "/api/type-aliases/TSelectEvent" },
165-
{ text: "TClearSelectionEvent", link: "/api/type-aliases/TClearSelectionEvent" },
166-
{ text: "TMarkEvent", link: "/api/type-aliases/TMarkEvent" },
167-
{ text: "TUnmarkEvent", link: "/api/type-aliases/TUnmarkEvent" },
169+
{ text: "TUnselectEvent", link: "/api/type-aliases/TUnselectEvent" },
170+
{ text: "TStyleEvent", link: "/api/type-aliases/TStyleEvent" },
171+
{ text: "TUnstyleEvent", link: "/api/type-aliases/TUnstyleEvent" },
168172
],
169173
},
170174
{

docs/guide/commands/delete.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ await tw.play();
121121

122122
## Interaction with cursor position
123123

124-
`.delete()` removes text backward from wherever the cursor currently is. Use `.moveCursor()` first to delete from a specific position:
124+
`.delete()` removes text backward from wherever the cursor currently is. Use `.move()` first to delete from a specific position:
125125

126126
```ts
127127
tw.timeline
128128
.type("Hello World")
129-
.moveCursor(5) // cursor is now at index 5 (between "Hello" and " ")
129+
.move(5) // cursor is now at index 5 (between "Hello" and " ")
130130
.delete(5, { by: "char", interval: 60 }); // removes "Hello"
131131

132132
await tw.play();
@@ -140,7 +140,7 @@ If the targeted cursor has an active selection when `.delete()` fires, the entir
140140
```ts
141141
tw.timeline
142142
.type("Hello World")
143-
.moveCursor(6)
143+
.move(6)
144144
.select(5) // selects "World"
145145
.delete(1); // deletes the selection in one step
146146

docs/guide/commands/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Commands are the building blocks of a typewriter animation. They are scheduled o
99
| [Type](/guide/commands/type) | `.type(text, options?)` | ✅ yes | ✅ yes — inserts text |
1010
| [Wait](/guide/commands/wait) | `.wait(duration)` | ✅ yes | ❌ no |
1111
| [Delete](/guide/commands/delete) | `.delete(count, options?)` | ✅ yes | ✅ yes — removes text |
12-
| [Move Cursor](/guide/commands/move-cursor) | `.moveCursor(index, options?)` | ❌ instant | ❌ no |
12+
| [Move](/guide/commands/move) | `.move(index, options?)` | ❌ instant | ❌ no |
1313
| [Select](/guide/commands/select) | `.select(count, options?)` | ❌ instant | ❌ no |
14-
| [Clear Selection](/guide/commands/clear-selection) | `.clearSelection(options?)` | ❌ instant | ❌ no |
15-
| [Mark](/guide/commands/mark) | `.mark(style, range, options?)` | ❌ instant | ✅ yes — applies style |
16-
| [Unmark](/guide/commands/unmark) | `.unmark(range, options?)` | ❌ instant | ✅ yes — removes style |
14+
| [Unselect](/guide/commands/unselect) | `.unselect(options?)` | ❌ instant | ❌ no |
15+
| [Style](/guide/commands/style) | `.style(style, range, options?)` | ❌ instant | ✅ yes — applies style |
16+
| [Unstyle](/guide/commands/unstyle) | `.unstyle(range, options?)` | ❌ instant | ✅ yes — removes style |
1717
| [Call](/guide/commands/call) | `.call(fn, options?)` | ❌ instant | ❌ no |
1818

1919
## Shared options
@@ -86,9 +86,9 @@ The `callback` function receives a `TCallbackContext`:
8686
- [type](/guide/commands/type)
8787
- [wait](/guide/commands/wait)
8888
- [delete](/guide/commands/delete)
89-
- [moveCursor](/guide/commands/move-cursor)
89+
- [move](/guide/commands/move)
9090
- [select](/guide/commands/select)
91-
- [clearSelection](/guide/commands/clear-selection)
92-
- [mark](/guide/commands/mark)
93-
- [unmark](/guide/commands/unmark)
91+
- [unselect](/guide/commands/unselect)
92+
- [style](/guide/commands/style)
93+
- [unstyle](/guide/commands/unstyle)
9494
- [call](/guide/commands/call)
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# `.moveCursor()` — reposition the cursor
1+
# `.move()` — reposition the cursor
22

33
Teleports the cursor to a given absolute document index instantly.
44

55
```ts
6-
tw.timeline.moveCursor(index: number, options?: TMoveCursorOptions): TimelineBuilder
6+
tw.timeline.move(index: number, options?: TMoveOptions): TimelineBuilder
77
```
88

9-
`.moveCursor()` is an **instant command**. It produces a single event at the current timeline clock position and does **not** advance the clock. Commands after it start at the same timestamp.
9+
`.move()` is an **instant command**. It produces a single event at the current timeline clock position and does **not** advance the clock. Commands after it start at the same timestamp.
1010

1111
## Options
1212

1313
```ts
14-
type TMoveCursorOptions = {
14+
type TMoveOptions = {
1515
cursor?: TCursorSelector; // default: "main"
1616
before?: TCallbackHook;
1717
after?: TCallbackHook;
@@ -30,7 +30,7 @@ type TMoveCursorOptions = {
3030

3131
- `index` is an **absolute** character index into the document text (`0` = before the first character, `text.length` = after the last character).
3232
- `index` is **clamped** to `[0, document.text.length]` — values outside this range are silently clamped, not rejected.
33-
- The cursor's current **selection is cleared** when `.moveCursor()` fires.
33+
- The cursor's current **selection is cleared** when `.move()` fires.
3434
- The move is invisible — no visual transition occurs, the cursor jumps immediately.
3535
- Subsequent `.type()` calls insert at the new cursor position.
3636
- Subsequent `.delete()` calls remove backward from the new cursor position.
@@ -44,7 +44,7 @@ type TMoveCursorOptions = {
4444
tw.timeline
4545
.type("world", { by: "char", interval: 80 })
4646
.wait(400)
47-
.moveCursor(0)
47+
.move(0)
4848
.type("Hello ", { by: "char", interval: 80 });
4949

5050
await tw.play();
@@ -56,7 +56,7 @@ await tw.play();
5656
```ts
5757
tw.timeline
5858
.type("Helloworld", { by: "char", interval: 80 })
59-
.moveCursor(5)
59+
.move(5)
6060
.type(" ");
6161

6262
await tw.play();
@@ -69,7 +69,7 @@ await tw.play();
6969
tw.timeline
7070
.type("Hello World", { by: "char", interval: 80 })
7171
.wait(600)
72-
.moveCursor(6) // position before "World"
72+
.move(6) // position before "World"
7373
.delete(5, { by: "char", interval: 60 }) // remove "World"
7474
.type("TypewriterJS", { by: "char", interval: 80 });
7575

@@ -82,35 +82,35 @@ await tw.play();
8282
```ts
8383
tw.timeline
8484
.type("Hello", { cursor: ["a", "b"] })
85-
.moveCursor(0, { cursor: "a" }) // move only cursor "a"
85+
.move(0, { cursor: "a" }) // move only cursor "a"
8686
.type(">> ", { cursor: "a" }); // cursor "a" prepends
8787

8888
await tw.play();
8989
```
9090

9191
## Interaction with selections
9292

93-
`.moveCursor()` always clears the selection of the targeted cursor. This is the standard way to deselect after a `.select()` command:
93+
`.move()` always clears the selection of the targeted cursor. This is the standard way to deselect after a `.select()` command:
9494

9595
```ts
9696
tw.timeline
9797
.type("Hello World")
98-
.moveCursor(6)
98+
.move(6)
9999
.select(5) // selects "World"
100-
.mark("highlight", "selection") // style the selection
101-
.moveCursor(11); // deselect — cursor goes to end
100+
.style("highlight", "selection") // style the selection
101+
.move(11); // deselect — cursor goes to end
102102

103103
await tw.play();
104104
```
105105

106106
## Clock behavior
107107

108-
Because `.moveCursor()` does not advance the clock, any timed command that follows starts at the same timestamp as if the move were not there:
108+
Because `.move()` does not advance the clock, any timed command that follows starts at the same timestamp as if the move were not there:
109109

110110
```ts
111111
tw.timeline
112112
.type("Hello", { interval: 80 }) // ends at 5 × 80 = 400 ms
113-
.moveCursor(0) // no clock change — still at 400 ms
113+
.move(0) // no clock change — still at 400 ms
114114
.type(">> ", { interval: 80 }); // starts at 400 ms
115115

116116
await tw.play();
@@ -123,12 +123,12 @@ await tw.play();
123123
- **`index < 0`** — clamped to `0`.
124124
- **`index > text.length`** — clamped to `text.length`.
125125
- **Calling on an empty document** — clamped to `0`; effectively a no-op.
126-
- **Consecutive `.moveCursor()` calls** — each fires at the same timestamp and replaces the previous cursor position; only the last one has an observable effect on subsequent commands.
126+
- **Consecutive `.move()` calls** — each fires at the same timestamp and replaces the previous cursor position; only the last one has an observable effect on subsequent commands.
127127

128128
## Type reference
129129

130-
- [`TMoveCursorOptions`](/api/type-aliases/TMoveCursorOptions)
131-
- [`TMoveCursorCommand`](/api/type-aliases/TMoveCursorCommand)
130+
- [`TMoveOptions`](/api/type-aliases/TMoveOptions)
131+
- [`TMoveCommand`](/api/type-aliases/TMoveCommand)
132132
- [`TCursorSelector`](/api/type-aliases/TCursorSelector)
133133
- [`TCallbackHook`](/api/type-aliases/TCallbackHook)
134134
- [`TAudioCommandOverride`](/api/type-aliases/TAudioCommandOverride)

docs/guide/commands/select.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type TSelectOptions = {
3434
- A negative `count` selects **backward** from the cursor's current position.
3535
- The selection is **relative** to the cursor — it extends `count` units in the chosen direction from wherever the cursor currently sits.
3636
- The selection is stored on the cursor state and consumed by the DOM renderer to render a visual highlight.
37-
- The selection is **cleared** by any subsequent `.type()`, `.delete()`, or `.moveCursor()` command targeting the same cursor.
37+
- The selection is **cleared** by any subsequent `.type()`, `.delete()`, or `.move()` command targeting the same cursor.
3838
- Selections do **not** prevent the cursor from continuing to type — they are metadata describing a range, not a lock.
3939

4040
## Advance modes (`by`)
@@ -55,7 +55,7 @@ A selection exists from the moment `.select()` fires until one of these clears i
5555

5656
1. `.type()` targeting the same cursor
5757
2. `.delete()` targeting the same cursor
58-
3. `.moveCursor()` targeting the same cursor
58+
3. `.move()` targeting the same cursor
5959
4. Another `.select()` targeting the same cursor (replaces the previous selection)
6060

6161
## Examples
@@ -66,7 +66,7 @@ A selection exists from the moment `.select()` fires until one of these clears i
6666
tw.timeline
6767
.type("Hello World", { by: "char", interval: 80 })
6868
.wait(600)
69-
.moveCursor(6)
69+
.move(6)
7070
.select(5); // selects "World"
7171

7272
await tw.play();
@@ -85,15 +85,15 @@ await tw.play();
8585
// "World" appears highlighted
8686
```
8787

88-
### Select then apply a mark
88+
### Select then apply a style
8989

9090
```ts
9191
tw.timeline
9292
.type("Hello World", { by: "char", interval: 80 })
93-
.moveCursor(6)
93+
.move(6)
9494
.select(5) // selects "World"
95-
.mark("highlight", "selection") // applies style to selection range
96-
.moveCursor(11); // clear selection, move to end
95+
.style("highlight", "selection") // applies style to selection range
96+
.move(11); // clear selection, move to end
9797

9898
await tw.play();
9999
// "World" permanently carries the "highlight" class
@@ -105,7 +105,7 @@ await tw.play();
105105
tw.timeline
106106
.type("one two three", { by: "word", interval: 150 })
107107
.wait(400)
108-
.moveCursor(4)
108+
.move(4)
109109
.select(2, { by: "word" }); // selects "two three"
110110

111111
await tw.play();
@@ -116,7 +116,7 @@ await tw.play();
116116
```ts
117117
tw.timeline
118118
.type("Hello World", { by: "char", interval: 80 })
119-
.moveCursor(6)
119+
.move(6)
120120
.select(5) // selects "World"
121121
.type("TypewriterJS"); // replaces selection
122122

@@ -129,7 +129,7 @@ await tw.play();
129129
```ts
130130
tw.timeline
131131
.type("Hello World", { by: "char", interval: 80 })
132-
.moveCursor(6)
132+
.move(6)
133133
.select(5) // selects "World"
134134
.delete(1); // deletes the selection in one step
135135

@@ -145,7 +145,7 @@ Use the `cursor` option to create selections on specific cursors:
145145
tw.timeline
146146
.type("ABCDE", { cursor: ["a", "b"] })
147147
.select(3, { cursor: "a" }) // only cursor "a" creates a selection
148-
.mark("highlight", "selection", { cursor: "a" });
148+
.style("highlight", "selection", { cursor: "a" });
149149

150150
await tw.play();
151151
// "CDE" is highlighted (cursor "a" was at position 2 after typing 5 chars,

0 commit comments

Comments
 (0)