@staticcanvas/typeflow 0.34.0

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.
Files changed (178) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +637 -0
  3. package/branding/dist/ico/typeflow-logo-16x16.ico +0 -0
  4. package/branding/dist/ico/typeflow-logo-256x256.ico +0 -0
  5. package/branding/dist/ico/typeflow-logo-32x32.ico +0 -0
  6. package/branding/dist/ico/typeflow-logo-48x48.ico +0 -0
  7. package/branding/dist/png/typeflow-logo-1024x1024.png +0 -0
  8. package/branding/dist/png/typeflow-logo-128x128.png +0 -0
  9. package/branding/dist/png/typeflow-logo-16x16.png +0 -0
  10. package/branding/dist/png/typeflow-logo-256x256.png +0 -0
  11. package/branding/dist/png/typeflow-logo-512x512.png +0 -0
  12. package/branding/dist/png/typeflow-logo-64x64.png +0 -0
  13. package/branding/dist/webp/typeflow-logo-1024x1024.webp +0 -0
  14. package/branding/dist/webp/typeflow-logo-128x128.webp +0 -0
  15. package/branding/dist/webp/typeflow-logo-16x16.webp +0 -0
  16. package/branding/dist/webp/typeflow-logo-256x256.webp +0 -0
  17. package/branding/dist/webp/typeflow-logo-32x32.webp +0 -0
  18. package/branding/dist/webp/typeflow-logo-48x48.webp +0 -0
  19. package/branding/dist/webp/typeflow-logo-512x512.webp +0 -0
  20. package/branding/dist/webp/typeflow-logo-64x64.webp +0 -0
  21. package/branding/gen-logo.ps1 +14 -0
  22. package/branding/typeflow-logo.svg +162 -0
  23. package/dist/typeflow/LICENSE +21 -0
  24. package/dist/typeflow/README.md +231 -0
  25. package/dist/typeflow/branding/dist/ico/typeflow-logo-16x16.ico +0 -0
  26. package/dist/typeflow/branding/dist/ico/typeflow-logo-256x256.ico +0 -0
  27. package/dist/typeflow/branding/dist/ico/typeflow-logo-32x32.ico +0 -0
  28. package/dist/typeflow/branding/dist/ico/typeflow-logo-48x48.ico +0 -0
  29. package/dist/typeflow/branding/dist/png/typeflow-logo-1024x1024.png +0 -0
  30. package/dist/typeflow/branding/dist/png/typeflow-logo-128x128.png +0 -0
  31. package/dist/typeflow/branding/dist/png/typeflow-logo-16x16.png +0 -0
  32. package/dist/typeflow/branding/dist/png/typeflow-logo-256x256.png +0 -0
  33. package/dist/typeflow/branding/dist/png/typeflow-logo-512x512.png +0 -0
  34. package/dist/typeflow/branding/dist/png/typeflow-logo-64x64.png +0 -0
  35. package/dist/typeflow/branding/dist/webp/typeflow-logo-1024x1024.webp +0 -0
  36. package/dist/typeflow/branding/dist/webp/typeflow-logo-128x128.webp +0 -0
  37. package/dist/typeflow/branding/dist/webp/typeflow-logo-16x16.webp +0 -0
  38. package/dist/typeflow/branding/dist/webp/typeflow-logo-256x256.webp +0 -0
  39. package/dist/typeflow/branding/dist/webp/typeflow-logo-32x32.webp +0 -0
  40. package/dist/typeflow/branding/dist/webp/typeflow-logo-48x48.webp +0 -0
  41. package/dist/typeflow/branding/dist/webp/typeflow-logo-512x512.webp +0 -0
  42. package/dist/typeflow/branding/dist/webp/typeflow-logo-64x64.webp +0 -0
  43. package/dist/typeflow/branding/gen-logo.ps1 +14 -0
  44. package/dist/typeflow/branding/typeflow-logo.svg +162 -0
  45. package/dist/typeflow/dist/typeflow-caret.cjs +47 -0
  46. package/dist/typeflow/dist/typeflow-caret.cjs.map +1 -0
  47. package/dist/typeflow/dist/typeflow-caret.esm.js +47 -0
  48. package/dist/typeflow/dist/typeflow-caret.esm.js.map +1 -0
  49. package/dist/typeflow/dist/typeflow-caret.esm.min.js +2 -0
  50. package/dist/typeflow/dist/typeflow-caret.esm.min.js.map +1 -0
  51. package/dist/typeflow/dist/typeflow-caret.js +47 -0
  52. package/dist/typeflow/dist/typeflow-caret.js.map +1 -0
  53. package/dist/typeflow/dist/typeflow-caret.min.js +2 -0
  54. package/dist/typeflow/dist/typeflow-caret.min.js.map +1 -0
  55. package/dist/typeflow/dist/typeflow-caret.mjs +47 -0
  56. package/dist/typeflow/dist/typeflow-caret.mjs.map +1 -0
  57. package/dist/typeflow/dist/typeflow-debug.cjs +109 -0
  58. package/dist/typeflow/dist/typeflow-debug.cjs.map +1 -0
  59. package/dist/typeflow/dist/typeflow-debug.esm.js +109 -0
  60. package/dist/typeflow/dist/typeflow-debug.esm.js.map +1 -0
  61. package/dist/typeflow/dist/typeflow-debug.esm.min.js +2 -0
  62. package/dist/typeflow/dist/typeflow-debug.esm.min.js.map +1 -0
  63. package/dist/typeflow/dist/typeflow-debug.js +109 -0
  64. package/dist/typeflow/dist/typeflow-debug.js.map +1 -0
  65. package/dist/typeflow/dist/typeflow-debug.min.js +2 -0
  66. package/dist/typeflow/dist/typeflow-debug.min.js.map +1 -0
  67. package/dist/typeflow/dist/typeflow-debug.mjs +109 -0
  68. package/dist/typeflow/dist/typeflow-debug.mjs.map +1 -0
  69. package/dist/typeflow/dist/typeflow-extchars.cjs +66 -0
  70. package/dist/typeflow/dist/typeflow-extchars.cjs.map +1 -0
  71. package/dist/typeflow/dist/typeflow-extchars.esm.js +66 -0
  72. package/dist/typeflow/dist/typeflow-extchars.esm.js.map +1 -0
  73. package/dist/typeflow/dist/typeflow-extchars.esm.min.js +2 -0
  74. package/dist/typeflow/dist/typeflow-extchars.esm.min.js.map +1 -0
  75. package/dist/typeflow/dist/typeflow-extchars.js +66 -0
  76. package/dist/typeflow/dist/typeflow-extchars.js.map +1 -0
  77. package/dist/typeflow/dist/typeflow-extchars.min.js +2 -0
  78. package/dist/typeflow/dist/typeflow-extchars.min.js.map +1 -0
  79. package/dist/typeflow/dist/typeflow-extchars.mjs +66 -0
  80. package/dist/typeflow/dist/typeflow-extchars.mjs.map +1 -0
  81. package/dist/typeflow/dist/typeflow-keystroke.cjs +47 -0
  82. package/dist/typeflow/dist/typeflow-keystroke.cjs.map +1 -0
  83. package/dist/typeflow/dist/typeflow-keystroke.esm.js +47 -0
  84. package/dist/typeflow/dist/typeflow-keystroke.esm.js.map +1 -0
  85. package/dist/typeflow/dist/typeflow-keystroke.esm.min.js +2 -0
  86. package/dist/typeflow/dist/typeflow-keystroke.esm.min.js.map +1 -0
  87. package/dist/typeflow/dist/typeflow-keystroke.js +47 -0
  88. package/dist/typeflow/dist/typeflow-keystroke.js.map +1 -0
  89. package/dist/typeflow/dist/typeflow-keystroke.min.js +2 -0
  90. package/dist/typeflow/dist/typeflow-keystroke.min.js.map +1 -0
  91. package/dist/typeflow/dist/typeflow-keystroke.mjs +47 -0
  92. package/dist/typeflow/dist/typeflow-keystroke.mjs.map +1 -0
  93. package/dist/typeflow/dist/typeflow-metrics.cjs +76 -0
  94. package/dist/typeflow/dist/typeflow-metrics.cjs.map +1 -0
  95. package/dist/typeflow/dist/typeflow-metrics.esm.js +76 -0
  96. package/dist/typeflow/dist/typeflow-metrics.esm.js.map +1 -0
  97. package/dist/typeflow/dist/typeflow-metrics.esm.min.js +2 -0
  98. package/dist/typeflow/dist/typeflow-metrics.esm.min.js.map +1 -0
  99. package/dist/typeflow/dist/typeflow-metrics.js +76 -0
  100. package/dist/typeflow/dist/typeflow-metrics.js.map +1 -0
  101. package/dist/typeflow/dist/typeflow-metrics.min.js +2 -0
  102. package/dist/typeflow/dist/typeflow-metrics.min.js.map +1 -0
  103. package/dist/typeflow/dist/typeflow-metrics.mjs +76 -0
  104. package/dist/typeflow/dist/typeflow-metrics.mjs.map +1 -0
  105. package/dist/typeflow/dist/typeflow-parallel.cjs +3 -0
  106. package/dist/typeflow/dist/typeflow-parallel.cjs.map +1 -0
  107. package/dist/typeflow/dist/typeflow-parallel.esm.js +3 -0
  108. package/dist/typeflow/dist/typeflow-parallel.esm.js.map +1 -0
  109. package/dist/typeflow/dist/typeflow-parallel.esm.min.js +2 -0
  110. package/dist/typeflow/dist/typeflow-parallel.esm.min.js.map +1 -0
  111. package/dist/typeflow/dist/typeflow-parallel.js +3 -0
  112. package/dist/typeflow/dist/typeflow-parallel.js.map +1 -0
  113. package/dist/typeflow/dist/typeflow-parallel.min.js +2 -0
  114. package/dist/typeflow/dist/typeflow-parallel.min.js.map +1 -0
  115. package/dist/typeflow/dist/typeflow-parallel.mjs +3 -0
  116. package/dist/typeflow/dist/typeflow-parallel.mjs.map +1 -0
  117. package/dist/typeflow/dist/typeflow-webaudio.cjs +81 -0
  118. package/dist/typeflow/dist/typeflow-webaudio.cjs.map +1 -0
  119. package/dist/typeflow/dist/typeflow-webaudio.esm.js +81 -0
  120. package/dist/typeflow/dist/typeflow-webaudio.esm.js.map +1 -0
  121. package/dist/typeflow/dist/typeflow-webaudio.esm.min.js +2 -0
  122. package/dist/typeflow/dist/typeflow-webaudio.esm.min.js.map +1 -0
  123. package/dist/typeflow/dist/typeflow-webaudio.js +81 -0
  124. package/dist/typeflow/dist/typeflow-webaudio.js.map +1 -0
  125. package/dist/typeflow/dist/typeflow-webaudio.min.js +2 -0
  126. package/dist/typeflow/dist/typeflow-webaudio.min.js.map +1 -0
  127. package/dist/typeflow/dist/typeflow-webaudio.mjs +81 -0
  128. package/dist/typeflow/dist/typeflow-webaudio.mjs.map +1 -0
  129. package/dist/typeflow/dist/typeflow.cjs +277 -0
  130. package/dist/typeflow/dist/typeflow.cjs.map +1 -0
  131. package/dist/typeflow/dist/typeflow.esm.js +277 -0
  132. package/dist/typeflow/dist/typeflow.esm.js.map +1 -0
  133. package/dist/typeflow/dist/typeflow.esm.min.js +2 -0
  134. package/dist/typeflow/dist/typeflow.esm.min.js.map +1 -0
  135. package/dist/typeflow/dist/typeflow.js +277 -0
  136. package/dist/typeflow/dist/typeflow.js.map +1 -0
  137. package/dist/typeflow/dist/typeflow.min.js +2 -0
  138. package/dist/typeflow/dist/typeflow.min.js.map +1 -0
  139. package/dist/typeflow/dist/typeflow.mjs +277 -0
  140. package/dist/typeflow/dist/typeflow.mjs.map +1 -0
  141. package/dist/typeflow/jsr.jsonc +27 -0
  142. package/dist/typeflow/package.json +79 -0
  143. package/dist/typeflow/src/typeflow-audio-presets.js +137 -0
  144. package/dist/typeflow/src/typeflow-caret.d.ts +65 -0
  145. package/dist/typeflow/src/typeflow-caret.js +303 -0
  146. package/dist/typeflow/src/typeflow-debug.d.ts +34 -0
  147. package/dist/typeflow/src/typeflow-debug.js +223 -0
  148. package/dist/typeflow/src/typeflow-extchars.d.ts +28 -0
  149. package/dist/typeflow/src/typeflow-extchars.js +132 -0
  150. package/dist/typeflow/src/typeflow-keystroke.d.ts +28 -0
  151. package/dist/typeflow/src/typeflow-keystroke.js +220 -0
  152. package/dist/typeflow/src/typeflow-metrics.d.ts +38 -0
  153. package/dist/typeflow/src/typeflow-metrics.js +556 -0
  154. package/dist/typeflow/src/typeflow-parallel.d.ts +36 -0
  155. package/dist/typeflow/src/typeflow-parallel.js +157 -0
  156. package/dist/typeflow/src/typeflow-webaudio.d.ts +83 -0
  157. package/dist/typeflow/src/typeflow-webaudio.js +517 -0
  158. package/dist/typeflow/src/typeflow.d.ts +328 -0
  159. package/dist/typeflow/src/typeflow.js +2119 -0
  160. package/jsr.jsonc +27 -0
  161. package/package.json +133 -0
  162. package/src/typeflow-audio-presets.js +137 -0
  163. package/src/typeflow-caret.d.ts +65 -0
  164. package/src/typeflow-caret.js +303 -0
  165. package/src/typeflow-debug.d.ts +34 -0
  166. package/src/typeflow-debug.js +223 -0
  167. package/src/typeflow-extchars.d.ts +28 -0
  168. package/src/typeflow-extchars.js +132 -0
  169. package/src/typeflow-keystroke.d.ts +28 -0
  170. package/src/typeflow-keystroke.js +220 -0
  171. package/src/typeflow-metrics.d.ts +38 -0
  172. package/src/typeflow-metrics.js +556 -0
  173. package/src/typeflow-parallel.d.ts +36 -0
  174. package/src/typeflow-parallel.js +157 -0
  175. package/src/typeflow-webaudio.d.ts +83 -0
  176. package/src/typeflow-webaudio.js +517 -0
  177. package/src/typeflow.d.ts +328 -0
  178. package/src/typeflow.js +2119 -0
package/README.md ADDED
@@ -0,0 +1,637 @@
1
+ <div align="left">
2
+
3
+ ![TypeFlow Banner](https://r2os.staticcanvas.me/logos/typeflow/dist/webp/typeflow-logo-64x64.webp)
4
+
5
+ [![license](https://img.shields.io/gitlab/license/staticcanvas/typeflow?style=flat-square&logo=gitlab&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://gitlab.com/staticcanvas/typeflow)
6
+ [![gitlab-pipeline](https://img.shields.io/gitlab/pipeline-status/staticcanvas/typeflow?style=flat-square&logo=gitlab&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://gitlab.com/staticcanvas/typeflow/-/pipelines)
7
+ [![codecov](https://codecov.io/gl/staticcanvas/typeflow/branch/v0.34.0-release/graph/badge.svg?token=)](https://codecov.io/gl/staticcanvas/typeflow)
8
+ [![documentation](https://img.shields.io/badge/docs-online-42275a?style=flat-square&logo=gitbook&logoColor=e73827)](https://staticcanvas.gitlab.io/typeflow)
9
+ [![gitlab-issues](https://img.shields.io/gitlab/issues/open/staticcanvas/typeflow?style=flat-square&logo=gitlab&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://gitlab.com/staticcanvas/typeflow/-/work_items?sort=created_date&state=opened&first_page_size=20)
10
+
11
+ [![gitlab-release](https://img.shields.io/gitlab/v/release/staticcanvas/typeflow?style=flat-square&logo=gitlab&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://gitlab.com/staticcanvas/typeflow/-/releases/permalink/latest)
12
+ [![gitlab-tag](https://img.shields.io/gitlab/v/tag/staticcanvas/typeflow?style=flat-square&logo=gitlab&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://gitlab.com/staticcanvas/typeflow/-/tags)
13
+
14
+ [![npm-version](https://img.shields.io/npm/v/@staticcanvas/typeflow?style=flat-square&logo=npm&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://www.npmjs.com/package/@staticcanvas/typeflow)
15
+ [![npm-downloads](https://img.shields.io/npm/dw/@staticcanvas/typeflow?style=flat-square&logo=npm&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://www.npmjs.com/package/@staticcanvas/typeflow)
16
+
17
+ [![jsr-version](https://img.shields.io/jsr/v/%40staticcanvas/typeflow?style=flat-square&logo=jsr&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://jsr.io/%40staticcanvas/typeflow)
18
+ [![jsdelivr-hitsperweek](https://img.shields.io/jsdelivr/npm/hw/@staticcanvas/typeflow?style=flat-square&logo=jsdelivr&labelColor=%231e1e1e&color=%2342275a&logoColor=%23e73827)](https://cdn.jsdelivr.net/package/npm/@staticcanvas/typeflow)
19
+
20
+ [![runtime-badge](https://gitlab.com/api/v4/projects/staticcanvas%2Ftypeflow/jobs/artifacts/v0.36.9-release/raw/runtime-badge-flat.svg?job=generate-runtime-badge)](https://gitlab.com/api/v4/projects/staticcanvas%2Ftypeflow/jobs/artifacts/develop/raw/runtime-badge-flat.svg?job=generate-runtime-badge)
21
+
22
+ > **TypeFlow** is a lightweight, interruptible, framework-agnostic typewriter animation library designed for modern web applications and static sites.
23
+
24
+ </div>
25
+
26
+ > [!note]
27
+ > TypeFlow is in active development, core functionality has been completed but theere are still features to be added, bugs and polish to be done.
28
+
29
+ ---
30
+
31
+ > 🔹 Read the full documentation [here](https://staticcanvas.gitlab.io/typeflow/) \
32
+ > 🔹 Use the playground [here](https://staticcanvas.gitlab.io/typeflow/playground/)
33
+
34
+ ## **Overview**
35
+
36
+ TypeFlow delivers zero-dependency text animation with precise frame control, rich HTML tag preservation, automated sanitization, multi-style bidirectional erasing, sequential step orchestration, and integrations for React, Vue, Svelte, Solid.js, Alpine.js, Astro, and Web Components.
37
+
38
+ <details>
39
+ <summary><strong>📚Table of Contents</strong></summary>
40
+
41
+ - [Overview](#overview)
42
+ - [Features](#features)
43
+ - [Installation](#installation)
44
+ - [NPM](#npm)
45
+ - [JSR](#jsr)
46
+ - [CDN](#cdn)
47
+ - [Usage](#usage)
48
+ - [Basic Typing & Erasing](#basic-typing-erasing)
49
+ - [Multi-Directional Typing & Scramble Charsets](#multi-directional-typing-scramble-charsets)
50
+ - [Smart Morph Diffing](#smart-morph-diffing)
51
+ - [Real-Time LLM Token Streaming](#real-time-llm-token-streaming)
52
+ - [Animation Presets](#animation-presets)
53
+ - [HTML Mode with Sanitization](#html-mode-with-sanitization)
54
+ - [Sequential Multi-Step Orchestration & Viewport Triggers](#sequential-multi-step-orchestration-viewport-triggers)
55
+ - [Framework Adapters](#framework-adapters)
56
+ - [React](#react)
57
+ - [Vue](#vue)
58
+ - [Svelte](#svelte)
59
+ - [Solid.js](#solidjs)
60
+ - [Alpine.js](#alpinejs)
61
+ - [Astro](#astro)
62
+ - [Web Components](#web-components)
63
+ - [Angular](#angular)
64
+ - [Companion Extensions](#companion-extensions)
65
+ - [API Reference](#api-reference)
66
+ - [TypeFlowConfig](#typeflowconfig)
67
+ - [TypeFlowController](#typeflowcontroller)
68
+ - [Core Engine Methods](#core-engine-methods)
69
+ - [Development & NPM Scripts](#development-npm-scripts)
70
+ - [Extending TypeFlow & Developer Guide](#extending-typeflow-developer-guide)
71
+ - [1. Custom Audio Synthesizers & Keystroke Callbacks](#1-custom-audio-synthesizers-keystroke-callbacks)
72
+ - [Experimental Asciiam bridge](#experimental-asciiam-bridge)
73
+ - [2. Custom Scramble Charset & Character Pools](#2-custom-scramble-charset-character-pools)
74
+ - [3. Writing Custom Sequence Step Helpers](#3-writing-custom-sequence-step-helpers)
75
+ - [4. Creating Custom Framework Adapters](#4-creating-custom-framework-adapters)
76
+ - [Benchmarks](#benchmarks)
77
+ - [Synthetic Benchmarks (Node.js and JSDOM)](#synthetic-benchmarks-nodejs-and-jsdom)
78
+ - [Real-browser capacity benchmark](#real-browser-capacity-benchmark)
79
+ - [License](#license)
80
+
81
+ </details>
82
+
83
+ ## **Features**
84
+
85
+ - **Zero Runtime Dependencies**: Pure ECMAScript with native DOM batching.
86
+ - **Safe HTML Support**: Parses and types structured markup while keeping HTML tags balanced and sanitized against script injection.
87
+ - **`Intl.Segmenter` Powered**: Accurate grapheme and word segmentation for international character clusters and compound emojis (`🚀`, `👨‍👩‍👧‍👦`).
88
+ - **Multi-Directional Reveals & Erasing**: Type left-to-right, right-to-left, or expand center-outward (`direction: 'center'`). Erase via backspace (`end`), left erosion (`start`), inward shrink (`center`), opacity fade (`fade`), or matrix decrypt (`scramble`).
89
+ - **Spatial Word-Motion Styles**: Layout-stable word reveals and erases — `word-fade`, directional `float-in-top/bottom/left/right`, and depth-scaled `zoom-in-space` — with configurable stagger, distance, and easing.
90
+ - **Scramble Charset Presets**: Built-in glyph presets (`matrix`, `blocks`, `ascii`, `ascii-extended`, `binary`, `hex`, `braille`, `runic`, `cyber`) and custom glyph overrides.
91
+ - **Procedural Web Audio Keystrokes**: Zero-asset procedural audio clicks, terminal pings, and cyber synth sounds (`audio: 'mechanical' | 'beep' | 'synth'`).
92
+ - **Smart Morph Diff Typing**: Computes longest common prefixes and only backspaces changed trailing characters (`TypeFlow.morph()`).
93
+ - **Real-Time Stream Ingestion**: Non-blocking FIFO token stream buffer for LLM / SSE token ingestion (`TypeFlow.stream()`).
94
+ - **Animation Presets**: One-line configuration profiles (`TypeFlow.preset('cyberpunk')`, `'terminal'`, `'writer'`, `'matrix'`, `'blocks'`, `'subtle'`).
95
+ - **CLS Layout Shift Prevention**: Automatic dimension stabilization (`TypeFlow.fit()`) preventing Cumulative Layout Shift during text rotations.
96
+ - **Natural Cadence Punctuation Pacing**: Micro-pauses at commas, colons, and sentence stops (`naturalCadence: true`).
97
+ - **Sequence Orchestration & Viewport Triggers**: Coordinate multi-step animations (`type`, `erase`, `pause`, `visible`, `call`) with `seq.visible()` IntersectionObserver delays.
98
+ - **Rotator Pattern & DOM Watcher**: Built-in helper for cyclic word replacements and automated mutation listeners.
99
+ - **Reduced Motion Compliance**: Respects `prefers-reduced-motion` settings automatically.
100
+ - **Interactive Caret**: Standalone, zero-dependency editable cursor (`Caret()`) — `jump()`/`move()` reposition instantly, `deleteChar()`/`deleteWord()` edit in place, `insert()` types new text at the caret position.
101
+ - **Framework Integrations**: First-class runtime adapters for React (`createTypeFlowReact`), Vue (`createTypeFlowVue`), Svelte (`createTypeFlowSvelte`), Solid.js (`createTypeFlowSolid`), and Alpine.js (`createTypeFlowAlpine`), plus native Web Components and framework-friendly Astro usage.
102
+
103
+ ## **Installation**
104
+
105
+ ### NPM
106
+
107
+ ```bash
108
+ npm install @staticcanvas/typeflow
109
+ ```
110
+
111
+ ### JSR
112
+
113
+ ```bash
114
+ npx jsr add @staticcanvas/typeflow
115
+ ```
116
+
117
+ ### CDN
118
+
119
+ ```html
120
+ <!-- UMD (Global window.TypeFlow) -->
121
+ <script src="https://cdn.jsdelivr.net/npm/@staticcanvas/typeflow/dist/typeflow.js"></script>
122
+
123
+ <!-- ESM Module -->
124
+ <script type="module">
125
+ import {
126
+ TypeFlow,
127
+ seq,
128
+ } from 'https://cdn.jsdelivr.net/npm/@staticcanvas/typeflow/dist/typeflow.esm.js';
129
+ </script>
130
+ ```
131
+
132
+ ## **Usage**
133
+
134
+ ### Basic Typing & Erasing
135
+
136
+ ```javascript
137
+ import { TypeFlow } from '@staticcanvas/typeflow';
138
+
139
+ // Plain text typing with natural punctuation cadence and procedural audio
140
+ const controller = TypeFlow.type('#headline', 'Building resilient interfaces. Zero dependencies.', {
141
+ speed: 45,
142
+ naturalCadence: true,
143
+ audio: 'mechanical',
144
+ cursor: '|',
145
+ cursorBlink: true,
146
+ onComplete: (text) => console.log('Typing complete:', text),
147
+ });
148
+
149
+ // Erase inward toward center
150
+ TypeFlow.erase('#headline', {
151
+ speed: 20,
152
+ eraseStyle: 'center',
153
+ });
154
+ ```
155
+
156
+ ### Multi-Directional Typing & Scramble Charsets
157
+
158
+ ```javascript
159
+ import { TypeFlow } from '@staticcanvas/typeflow';
160
+
161
+ // Expand outward from center with matrix scramble glyphs
162
+ TypeFlow.type('#terminal', 'SYSTEM SECURE: ACCESS GRANTED', {
163
+ direction: 'center',
164
+ typeStyle: 'scramble',
165
+ scrambleCharset: 'matrix',
166
+ scrambleRounds: 2,
167
+ audio: 'synth',
168
+ speed: 35,
169
+ });
170
+ ```
171
+
172
+ ### Smart Morph Diffing
173
+
174
+ ```javascript
175
+ import { TypeFlow } from '@staticcanvas/typeflow';
176
+
177
+ // Automatically keeps "TypeFlow is " and only erases & replaces the trailing word
178
+ await TypeFlow.type('#headline', 'TypeFlow is fast');
179
+ await TypeFlow.morph('#headline', 'TypeFlow is lightweight');
180
+ ```
181
+
182
+ ### Real-Time LLM Token Streaming
183
+
184
+ ```javascript
185
+ import { TypeFlow } from '@staticcanvas/typeflow';
186
+
187
+ const stream = TypeFlow.stream('#ai-response', { speed: 20, cursor: '|' });
188
+
189
+ // Push incoming SSE / WebSocket chunks seamlessly
190
+ sse.onmessage = (event) => {
191
+ stream.push(event.data);
192
+ };
193
+ ```
194
+
195
+ ### Animation Presets
196
+
197
+ ```javascript
198
+ import { TypeFlow } from '@staticcanvas/typeflow';
199
+
200
+ // Cyberpunk scramble decrypt preset
201
+ TypeFlow.type('#cyber', 'NEURAL LINK ESTABLISHED', TypeFlow.preset('cyberpunk'));
202
+
203
+ // Classic typewriter with human punctuation cadence
204
+ TypeFlow.type('#story', 'Chapter 1. It was a dark, stormy night...', TypeFlow.preset('writer'));
205
+ ```
206
+
207
+ ### HTML Mode with Sanitization
208
+
209
+ ```javascript
210
+ import { TypeFlow } from '@staticcanvas/typeflow';
211
+
212
+ TypeFlow.type(
213
+ '#output',
214
+ 'Deploy to <strong>Production</strong> with <span class="badge">Zero Downtime</span>',
215
+ {
216
+ html: true,
217
+ speed: 30,
218
+ allowedTags: ['strong', 'span'],
219
+ allowedAttributes: { span: ['class'] },
220
+ }
221
+ );
222
+ ```
223
+
224
+ ### Sequential Multi-Step Orchestration & Viewport Triggers
225
+
226
+ ```javascript
227
+ import { TypeFlow, seq } from '@staticcanvas/typeflow';
228
+
229
+ TypeFlow.sequence(
230
+ [
231
+ seq.visible('#step-1'), // Waits until element scrolls into view
232
+ seq.type('#step-1', 'Initializing runtime kernel...'),
233
+ seq.pause(600),
234
+ seq.call(() => console.log('Phase 1 complete')),
235
+ seq.erase('#step-1', { eraseStyle: 'fade', duration: 300 }),
236
+ seq.type('#step-2', 'All systems operational.'),
237
+ ],
238
+ { repeat: 1 }
239
+ );
240
+ ```
241
+
242
+ ### Framework Adapters
243
+
244
+ #### React
245
+
246
+ ```jsx
247
+ import React from 'react';
248
+ import { createTypeFlowReact } from '@staticcanvas/typeflow';
249
+
250
+ const useTypeFlow = createTypeFlowReact(React);
251
+
252
+ function Headline() {
253
+ const headlineRef = useTypeFlow('Welcome to StaticCanvas', { speed: 40 });
254
+ return <h1 ref={headlineRef} />;
255
+ }
256
+ ```
257
+
258
+ `createTypeFlowSequenceReact(React)` returns a companion `useTypeFlowSequence(buildSteps, deps)` hook for multi-step `seq` orchestration inside a component.
259
+
260
+ #### Vue
261
+
262
+ ```vue
263
+ <script setup>
264
+ import * as Vue from 'vue';
265
+ import { createTypeFlowVue } from '@staticcanvas/typeflow';
266
+
267
+ const useTypeFlow = createTypeFlowVue(Vue);
268
+ const text = Vue.ref('Reactive Typewriter');
269
+ const headlineRef = useTypeFlow(() => text.value, { speed: 50 });
270
+ </script>
271
+
272
+ <template>
273
+ <h1 ref="headlineRef"></h1>
274
+ </template>
275
+ ```
276
+
277
+ `createTypeFlowSequenceVue(Vue)` returns a companion `useTypeFlowSequence(buildSteps)` hook that returns a runner function for multi-step `seq` orchestration.
278
+
279
+ #### Svelte
280
+
281
+ ```svelte
282
+ <script>
283
+ import { createTypeFlowSvelte } from '@staticcanvas/typeflow';
284
+ const typeflow = createTypeFlowSvelte();
285
+ </script>
286
+
287
+ <h1 use:typeflow={{ text: 'Svelte Action Animation', config: { speed: 40 } }}></h1>
288
+ ```
289
+
290
+ #### Solid.js
291
+
292
+ ```jsx
293
+ import * as Solid from 'solid-js';
294
+ import { createTypeFlowSolid } from '@staticcanvas/typeflow';
295
+
296
+ const useTypeFlow = createTypeFlowSolid(Solid);
297
+
298
+ export function Hero() {
299
+ const [headline, setHeadline] = Solid.createSignal('Solid.js Reactive Typography');
300
+ const ref = useTypeFlow(headline, { speed: 40 });
301
+ return <h1 ref={ref} />;
302
+ }
303
+ ```
304
+
305
+ #### Alpine.js
306
+
307
+ ```html
308
+ <script type="module">
309
+ import Alpine from 'alpinejs';
310
+ import { createTypeFlowAlpine } from '@staticcanvas/typeflow';
311
+
312
+ createTypeFlowAlpine(Alpine);
313
+ Alpine.start();
314
+ </script>
315
+
316
+ <div x-data="{ title: 'Alpine.js Typography' }">
317
+ <h1 x-typeflow="{ text: title, config: { speed: 40 } }"></h1>
318
+ </div>
319
+ ```
320
+
321
+ #### Astro
322
+
323
+ Astro uses TypeFlow's browser-native ESM integration in a client island. Add `client:load` (or another Astro client directive) to ensure the component runs in the browser.
324
+
325
+ ```astro
326
+ ---
327
+ import { TypeFlow } from '@staticcanvas/typeflow';
328
+
329
+ const text = 'Astro island typography';
330
+ ---
331
+
332
+ <h1 id="headline">{text}</h1>
333
+
334
+ <script>
335
+ import { TypeFlow } from '@staticcanvas/typeflow';
336
+
337
+ const target = document.querySelector('#headline');
338
+ if (target) TypeFlow.type(target, target.textContent ?? '', { speed: 40 });
339
+ </script>
340
+ ```
341
+
342
+ For an Astro component that must hydrate with the rest of an island, place the DOM animation in a client component or use the native `<type-flow>` element below. TypeFlow does not require an Astro-specific runtime package.
343
+
344
+ #### Web Components
345
+
346
+ ```html
347
+ <script type="module">
348
+ import { defineTypeFlowElement } from '@staticcanvas/typeflow';
349
+ defineTypeFlowElement();
350
+ </script>
351
+
352
+ <type-flow text="Framework-neutral custom element" speed="40"></type-flow>
353
+ ```
354
+
355
+ #### Angular
356
+
357
+ TypeFlow does not ship an Angular-specific factory. Angular applications can use the core `TypeFlow` API from a small attribute directive and stop the returned controller in `ngOnDestroy`; the documentation site includes a complete directive recipe.
358
+
359
+ ## Companion Extensions
360
+
361
+ TypeFlow is built with a sub-7.2 KB hyper-optimized core engine. For developers requiring advanced capabilities, TypeFlow provides seven modular, tree-shakeable companion extensions:
362
+
363
+ | Package Subpath | Module Name | Description |
364
+ | :--------------------------------- | :------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
365
+ | `@staticcanvas/typeflow/metrics` | `TypeFlowMetrics` | Floating diagnostic HUD metrics badge tracking FPS, active instances, typed/erased counters, render latency, and DOM mutations. |
366
+ | `@staticcanvas/typeflow/debug` | `TypeFlowDebug` | Diagnostic tracing with `@staticcanvas/logcad` integration, colored console groups, and controller event history. |
367
+ | `@staticcanvas/typeflow/webaudio` | `TypeFlowWebAudio` | Zero-asset Web Audio procedural synthesis with clicky mechanical switches (Blue, Red, Brown), teletype, cyber synths, and stereo panning. |
368
+ | `@staticcanvas/typeflow/parallel` | `installParallel` | Experimental, explicit opt-in parallel step orchestration with bounded concurrency and ordered results. |
369
+ | `@staticcanvas/typeflow/keystroke` | `TypeFlowKeystroke` | Human typing simulation: QWERTY physical finger travel distance, thought pauses, and realistic typo injection with auto-correction backspaces. |
370
+ | `@staticcanvas/typeflow/extchars` | `TypeFlowExtChars` | Extended Unicode glyph presets for decrypt effects: Egyptian Hieroglyphs, Runic, Ogham, Coptic, Katakana, Box-Drawing, and Braille. |
371
+ | `@staticcanvas/typeflow/caret` | `Caret` | Persistent, editable cursor bound to an element's text: `jump()`/`move()` reposition it, `deleteChar()`/`deleteWord()` edit at that position, `insert()` types new text in. |
372
+
373
+ ```javascript
374
+ // Example: Metrics HUD + Procedural Web Audio
375
+ import { TypeFlow } from '@staticcanvas/typeflow';
376
+ import { TypeFlowMetrics } from '@staticcanvas/typeflow/metrics';
377
+ import { createKeystrokeAudio } from '@staticcanvas/typeflow/webaudio';
378
+
379
+ TypeFlowMetrics.mount({ position: 'bottom-right' });
380
+
381
+ TypeFlow.type('#terminal', 'System diagnostics active.', {
382
+ audio: createKeystrokeAudio('mechanical-blue'),
383
+ speed: 35,
384
+ });
385
+ ```
386
+
387
+ ## **API Reference**
388
+
389
+ ### `TypeFlowConfig`
390
+
391
+ | Property | Type | Default | Description |
392
+ | :---------------------- | :------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------ | :----------------------------------------------------------------------------- |
393
+ | `speed` | `number` | `50` (type) / `25` (erase) | Milliseconds per character / word unit. |
394
+ | `delay` | `number` | `0` | Delay before animation starts in milliseconds. |
395
+ | `speedVariance` | `number` | `0` | Random variance range in milliseconds per unit. |
396
+ | `naturalCadence` | `boolean` | `false` | Automatic micro-pauses at punctuation (. , ! ?) and word breaks. |
397
+ | `granularity` | `"grapheme" \| "word"` | `"grapheme"` | Unit segmentation mode using `Intl.Segmenter`. |
398
+ | `direction` | `"left" \| "right" \| "center"` | `"left"` | Typing reveal direction (LTR, RTL, center-outward). |
399
+ | `typeStyle` | `"char" \| "word" \| "scramble" \| "fade-trail" \| "word-fade" \| "float-in-*" \| "zoom-in-space"` | `"char"` | Typing reveal style, including stable-layout opacity and spatial word motion. |
400
+ | `wordOrder` | `"left-to-right" \| "right-to-left" \| "random"` | `"left-to-right"` | Word reveal or erase order without changing the element's bidi direction. |
401
+ | `wordLayout` | `"opacity" \| "placeholder"` | `"opacity"` | Stable word layout strategy used by `word-fade`. |
402
+ | `wordFadeDuration` | `number` | `280` | Opacity transition duration for each word in milliseconds. |
403
+ | `wordStagger` | `number` | Current `speed` | Delay between consecutive word transitions. |
404
+ | `wordSeed` | `string \| number` | `undefined` | Reproducible shuffle seed when `wordOrder` is `"random"`. |
405
+ | `wordMotionDistance` | `number` | `24` | Translate distance in pixels for `float-in-*` word-motion styles. |
406
+ | `wordMotionDepth` | `number` | `160` | `translateZ` depth in pixels for the `zoom-in-space` word-motion style. |
407
+ | `wordMotionScale` | `number` | `0.82` | Starting scale (0-1) for the `zoom-in-space` word-motion style. |
408
+ | `wordMotionPerspective` | `number` | `600` | CSS `perspective` in pixels applied to the target element for `zoom-in-space`. |
409
+ | `wordMotionEasing` | `string` | `"ease"` | CSS timing function for `float-in-*` and `zoom-in-space` word transitions. |
410
+ | `trailFade` | `number \| boolean` | `undefined` | Soft trailing opacity gradient length in characters (e.g. `3` or `4`). |
411
+ | `trailMinOpacity` | `number` | `0.18` | Lowest opacity used by characters in the trailing fade. |
412
+ | `scrambleCharset` | `"matrix" \| "ascii" \| "ascii-extended" \| "blocks" \| "binary" \| "hex" \| "braille" \| "runic" \| "cyber"` | `undefined` | Built-in scramble glyph charset preset. |
413
+ | `scrambleGlyphs` | `string` | `"!<>-_\\/[]{}—=+*^?#________"` | Custom character pool used during scramble reveals. |
414
+ | `scrambleRounds` | `number` | `2` | Number of glyph iterations per character. |
415
+ | `scrambleColor` | `string` | `undefined` | CSS color applied to the active scramble glyph. |
416
+ | `scrambleGradient` | `string` | `undefined` | CSS gradient applied to the active scramble glyph; overrides `scrambleColor`. |
417
+ | `audio` | `"mechanical" \| "beep" \| "synth" \| boolean \| (() => void)` | `undefined` | Procedural Web Audio synthesized keystrokes or audio callback. |
418
+ | `cursor` | `string` | `"\|"` | Cursor character appended during animation. Set to `""` to disable. |
419
+ | `cursorBlink` | `boolean` | `true` | Enables post-completion cursor blinking. |
420
+ | `html` | `boolean` | `false` | Enables sanitized HTML parsing mode. |
421
+ | `mode` | `"replace" \| "append"` | `"replace"` | Clears target or appends to existing DOM child nodes. |
422
+ | `allowedTags` | `string[]` | Default allowlist | Array of permitted HTML tag names. |
423
+ | `allowedAttributes` | `Record<string, string[]>` | Default map | Map of allowed attributes per HTML tag. |
424
+ | `sanitizer` | `(html: string) => string` | `undefined` | Custom sanitizer function overriding default sanitizer. |
425
+ | `respectReducedMotion` | `boolean` | `true` | Instantly completes animation when reduced motion is preferred. |
426
+ | `ariaLive` | `"off" \| "polite" \| "assertive"` | `undefined` | ARIA live region policy applied to target element. |
427
+ | `eraseStyle` | `"end" \| "start" \| "center" \| "scramble" \| "fade-trail" \| "instant" \| "fade" \| "word-fade" \| "float-in-*" \| "zoom-in-space"` | `"end"` | Erase direction or visual transition mode. |
428
+ | `duration` | `number` | `250` | Transition duration in ms when `eraseStyle: "fade"`. |
429
+ | `preserveBaseline` | `boolean` | `true` | Preserves base content when erasing `append` mode elements. |
430
+ | `onStart` | `() => void` | `undefined` | Callback invoked when animation begins. |
431
+ | `onComplete` | `(text: string) => void` | `undefined` | Callback invoked upon animation completion. |
432
+ | `onInterrupt` | `() => void` | `undefined` | Callback invoked when controller is aborted before completion. |
433
+
434
+ ### `TypeFlowController`
435
+
436
+ | Method / Property | Type | Description |
437
+ | :---------------- | :------------------------ | :---------------------------------------------------------------------------- |
438
+ | `stop()` | `() => void` | Immediately terminates the active animation without rejecting promises. |
439
+ | `promise` | `Promise<TypeFlowResult>` | Resolves with `{ completed: boolean, text: string }` upon completion or stop. |
440
+
441
+ ### Core Engine Methods
442
+
443
+ | Method | Parameters | Returns | Description |
444
+ | :-------------------- | :-------------------------- | :--------------------------- | :----------------------------------------------------------------- |
445
+ | `TypeFlow.type()` | `target, text, config?` | `TypeFlowController` | Types text or sanitized HTML into target element. |
446
+ | `TypeFlow.erase()` | `target, config?` | `TypeFlowController` | Erases content from target element. |
447
+ | `TypeFlow.morph()` | `target, nextText, config?` | `TypeFlowController` | Smart diff typing: erases mismatched suffix and types new text. |
448
+ | `TypeFlow.stream()` | `target, config?` | `TypeFlowStreamController` | Creates a real-time FIFO chunk ingestion stream controller. |
449
+ | `TypeFlow.preset()` | `name, overrides?` | `TypeFlowConfig` | Returns pre-configured profile options for common animation types. |
450
+ | `TypeFlow.fit()` | `target, candidates` | `void` | Measures candidate phrases and locks min-width to prevent CLS. |
451
+ | `TypeFlow.stagger()` | `targets, texts?, config?` | `TypeFlowController` | Staggers typing across multiple elements with offset delays. |
452
+ | `TypeFlow.sequence()` | `steps, seqConfig?` | `TypeFlowController` | Executes an array of animation steps sequentially. |
453
+ | `TypeFlow.rotate()` | `target, words, config?` | `TypeFlowController` | Cycles through an array of strings in a loop. |
454
+ | `TypeFlow.watch()` | `container, selector, cb` | `{ disconnect: () => void }` | Observes and animates dynamically added DOM nodes. |
455
+ | `TypeFlow.stop()` | `target` | `void` | Stops the active animation and cursor timer for a target. |
456
+ | `TypeFlow.stopAll()` | `none` | `void` | Stops all currently active TypeFlow instances and timers. |
457
+ | `TypeFlow.isTyping()` | `target` | `boolean` | Returns active animation status for a target element. |
458
+
459
+ ---
460
+
461
+ ## **Development & NPM Scripts**
462
+
463
+ TypeFlow provides a full suite of NPM scripts for local development, automated testing, synthetic benchmarking, bundle validation, and documentation generation:
464
+
465
+ | Script | Command | Description |
466
+ | :----------------------------------------- | :------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------- |
467
+ | **`npm run dev`** | `vite` | Starts the local Vite development server for rapid iteration. |
468
+ | **`npm run build`** | `vite build` | Compiles production ESM, CJS, and UMD bundles into `dist/`. |
469
+ | **`npm test`** | `vitest run` | Runs the full Vitest unit test suite. |
470
+ | **`npm run test:coverage`** | `vitest run --coverage` | Executes tests with V8 code coverage report. |
471
+ | **`npm run benchmark`** | `node --expose-gc scripts/run-benchmark.mjs` | Runs the repeated 10k, 50k, 100k, and concurrency-tier synthetic suite. |
472
+ | **`npm run benchmark:quick`** | `node --expose-gc scripts/run-benchmark.mjs --quick` | Runs three samples over a reduced concurrency matrix. |
473
+ | **`npm run benchmark:md`** | `node --expose-gc scripts/run-benchmark.mjs --markdown` | Generates a Markdown result table. |
474
+ | **`npm run benchmark:json`** | `node --expose-gc scripts/run-benchmark.mjs --json` | Generates the benchmark report as JSON. |
475
+ | **`npm run benchmark:browser`** | Playwright Chromium + Firefox | Generates real-browser capacity JSON and Markdown with frame, heap, DOM, long-task, and leak metrics. |
476
+ | **`npm run benchmark:browser:quick`** | Reduced Playwright tier matrix | Regenerates a fast local browser benchmark sample. |
477
+ | **`npm run check:size`** | `node scripts/check-bundle-size.mjs` | Verifies the core bundle against the 10 KiB gzip budget. |
478
+ | **`npm run validate:docs-data`** | `node scripts/validate-doc-data.mjs` | Validates documentation splash data against its schema. |
479
+ | **`npm run check:quality`** | `npm run validate:docs-data && npm run build && npm run check:size && npm test` | Runs deterministic release quality checks. |
480
+ | **`npm run docs:build`** | `npm run build && hugo --source docs` | Compiles the static documentation and playground website into `public/`. |
481
+ | **`npm run release:docs:preview`** | Rivet release-document dry run | Previews generated release notes and Hugo changelog data from the latest reachable stable tag. |
482
+ | **`npm run release:docs`** | Rivet release-document sync | Updates `CHANGELOG.md`, `release-notes.md`, and `docs/data/changelog.json`; requires Rivet at `./rivet`. |
483
+ | **`npm run release:docs:rebuild:preview`** | Rivet history dry run | Previews a complete release-history rebuild across reachable tags. |
484
+ | **`npm run release:docs:rebuild`** | Rivet history sync | Rebuilds the canonical changelog and generated Hugo projection across all reachable tags. |
485
+ | **`npm run docs:serve`** | `npm run build && hugo server --source docs...` | Launches local live-reloading Hugo documentation server. |
486
+ | **`npm run lint`** | `eslint .` | Validates codebase with ESLint. |
487
+ | **`npm run lint:fix`** | `eslint . --fix` | Automatically resolves fixable lint issues. |
488
+ | **`npm run format`** | `prettier --write .` | Formats all source files with Prettier. |
489
+
490
+ ---
491
+
492
+ ## **Extending TypeFlow & Developer Guide**
493
+
494
+ ### 1. Custom Audio Synthesizers & Keystroke Callbacks
495
+
496
+ You can provide custom audio callbacks to `audio` or connect external audio engines (Tone.js, Howler.js, or Web Audio API `AudioContext`):
497
+
498
+ ```javascript
499
+ import { TypeFlow } from '@staticcanvas/typeflow';
500
+
501
+ const ctx = new AudioContext();
502
+
503
+ function playCustomBlip() {
504
+ const osc = ctx.createOscillator();
505
+ const gain = ctx.createGain();
506
+ osc.type = 'triangle';
507
+ osc.frequency.setValueAtTime(440, ctx.currentTime);
508
+ gain.gain.setValueAtTime(0.08, ctx.currentTime);
509
+ gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.04);
510
+ osc.connect(gain);
511
+ gain.connect(ctx.destination);
512
+ osc.start();
513
+ osc.stop(ctx.currentTime + 0.04);
514
+ }
515
+
516
+ TypeFlow.type('#headline', 'Custom Synthesized Audio', {
517
+ audio: playCustomBlip,
518
+ speed: 40,
519
+ });
520
+ ```
521
+
522
+ #### Experimental Asciiam bridge
523
+
524
+ An Asciiam adapter is being explored as a separate, opt-in integration. The
525
+ adapter would translate TypeFlow's unrestricted `audio` callback into small,
526
+ library-neutral keystroke events that Asciiam can consume and render on its
527
+ canvas. TypeFlow remains responsible only for text animation and event timing;
528
+ Asciiam remains responsible for audio visualization and canvas rendering.
529
+
530
+ This bridge is experimental, is not part of the stable TypeFlow API, and is
531
+ intentionally kept out of the documentation site until the event contract is
532
+ implemented and versioned. Neither library will require the other.
533
+
534
+ ### 2. Custom Scramble Charset & Character Pools
535
+
536
+ Override `scrambleGlyphs` with custom alphanumeric, hieroglyphic, or mathematical symbol pools:
537
+
538
+ ```javascript
539
+ import { TypeFlow } from '@staticcanvas/typeflow';
540
+
541
+ TypeFlow.type('#code', 'MATHEMATICAL_PROOF_VERIFIED', {
542
+ typeStyle: 'scramble',
543
+ scrambleGlyphs: '∑∏∫∮∇∆√∛∜∝∞∠∧∨∩∪≈≠≡≤≥',
544
+ scrambleRounds: 3,
545
+ speed: 45,
546
+ });
547
+ ```
548
+
549
+ ### 3. Writing Custom Sequence Step Helpers
550
+
551
+ Sequence steps in `TypeFlow.sequence` are plain JavaScript objects containing an `execute(runner)` function or one of the built-in step definitions:
552
+
553
+ ```javascript
554
+ import { TypeFlow, seq } from '@staticcanvas/typeflow';
555
+
556
+ // Custom async step that fetches dynamic data before continuing sequence
557
+ const fetchStep = {
558
+ type: 'custom-fetch',
559
+ execute: async () => {
560
+ const res = await fetch('/api/status');
561
+ const data = await res.json();
562
+ console.log('Dynamic status:', data);
563
+ },
564
+ };
565
+
566
+ TypeFlow.sequence([
567
+ seq.type('#status', 'Checking server health...'),
568
+ seq.pause(400),
569
+ fetchStep,
570
+ seq.erase('#status', { eraseStyle: 'fade' }),
571
+ seq.type('#status', 'All systems green.'),
572
+ ]);
573
+ ```
574
+
575
+ ### 4. Creating Custom Framework Adapters
576
+
577
+ TypeFlow exports a framework-agnostic engine. You can create custom adapters for any component library using its lifecycle hooks:
578
+
579
+ ```javascript
580
+ import { TypeFlow } from '@staticcanvas/typeflow';
581
+
582
+ export function createTypeFlowCustomHook(useRef, useEffect) {
583
+ return function useTypeFlow(text, config = {}) {
584
+ const ref = useRef(null);
585
+ useEffect(() => {
586
+ if (!ref.current) return;
587
+ const controller = TypeFlow.type(ref.current, text, config);
588
+ return () => controller.stop();
589
+ }, [text]);
590
+ return ref;
591
+ };
592
+ }
593
+ ```
594
+
595
+ ---
596
+
597
+ ## **Benchmarks**
598
+
599
+ TypeFlow is engineered with pre-compiled token caching and direct DOM window slicing, delivering sub-millisecond execution speeds even under 10,000+ character payloads.
600
+
601
+ ### Synthetic Benchmarks (Node.js and JSDOM)
602
+
603
+ The synthetic suite measures engine completion time and heap deltas. Each scenario runs warm-up iterations followed by seven measured samples and reports minimum, median, p95, maximum, and standard deviation. It covers:
604
+
605
+ - 10,000, 50,000, and 100,000-character plain-text final rendering;
606
+ - word segmentation, safe nested-HTML parsing, morphing, and instant erasing at each character tier;
607
+ - 1, 10, 25, 50, 100, 250, 500, and 1,000 concurrent short instances;
608
+ - raw and gzip production bundle size; and
609
+ - Node, JSDOM, operating system, processor, sample, garbage-collection, and commit metadata.
610
+
611
+ JSDOM does not calculate browser layout, paint, frame rate, GPU composition, or long tasks. These results must not be presented as a supported browser instance limit.
612
+
613
+ Run the suite with formatted Markdown output:
614
+
615
+ ```bash
616
+ npm run benchmark:md
617
+ ```
618
+
619
+ Generate JSON without npm's command banner when piping the result:
620
+
621
+ ```bash
622
+ npm run --silent benchmark:json > typeflow-benchmark.json
623
+ ```
624
+
625
+ ### Real-browser capacity benchmark
626
+
627
+ Run `npm run benchmark:browser` to measure active animation tiers in Chromium
628
+ and Firefox. The command writes [machine-readable results](benchmarks/results/browser-capacity.json)
629
+ and a [generated report](benchmarks/results/browser-capacity.md), including the
630
+ machine/browser environment and the exact capacity budgets. Metrics unavailable
631
+ in a browser remain `null`; they are never inferred from JSDOM or another engine.
632
+
633
+ ---
634
+
635
+ ### **License**
636
+
637
+ Distributed under the **MIT License**. See `LICENSE` for more information.