@vocasync/astro 1.0.1 → 2.1.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 (148) hide show
  1. package/README.md +735 -93
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api/client.js.map +1 -1
  4. package/dist/api/index.d.ts +1 -1
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api/index.js +1 -1
  7. package/dist/api/index.js.map +1 -1
  8. package/dist/cli.js.map +1 -1
  9. package/dist/components/AudioPlayer.astro +305 -1141
  10. package/dist/components/index.d.ts +10 -32
  11. package/dist/components/index.d.ts.map +1 -1
  12. package/dist/components/index.js +1 -3
  13. package/dist/components/index.js.map +1 -1
  14. package/dist/components/types.d.ts +117 -0
  15. package/dist/components/types.d.ts.map +1 -0
  16. package/dist/components/types.js +2 -0
  17. package/dist/components/types.js.map +1 -0
  18. package/dist/config/index.d.ts +3 -2
  19. package/dist/config/index.d.ts.map +1 -1
  20. package/dist/config/index.js +2 -1
  21. package/dist/config/index.js.map +1 -1
  22. package/dist/config/languages.d.ts +33 -0
  23. package/dist/config/languages.d.ts.map +1 -0
  24. package/dist/config/languages.js +167 -0
  25. package/dist/config/languages.js.map +1 -0
  26. package/dist/config/schema.d.ts +225 -172
  27. package/dist/config/schema.d.ts.map +1 -1
  28. package/dist/config/schema.js +45 -24
  29. package/dist/config/schema.js.map +1 -1
  30. package/dist/core/content-loader.js +1 -1
  31. package/dist/core/content-loader.js.map +1 -1
  32. package/dist/core/index.d.ts +2 -2
  33. package/dist/core/index.d.ts.map +1 -1
  34. package/dist/core/index.js +2 -2
  35. package/dist/core/index.js.map +1 -1
  36. package/dist/core/speech-builder.js.map +1 -1
  37. package/dist/index.d.ts +6 -7
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +5 -6
  40. package/dist/index.js.map +1 -1
  41. package/dist/integration.d.ts +28 -2
  42. package/dist/integration.d.ts.map +1 -1
  43. package/dist/integration.js +40 -3
  44. package/dist/integration.js.map +1 -1
  45. package/dist/lib/latex-to-speech/index.d.ts.map +1 -1
  46. package/dist/lib/latex-to-speech/index.js.map +1 -1
  47. package/dist/player-core/boot.d.ts +9 -0
  48. package/dist/player-core/boot.d.ts.map +1 -0
  49. package/dist/player-core/boot.js +59 -0
  50. package/dist/player-core/boot.js.map +1 -0
  51. package/dist/player-core/highlighter.d.ts +31 -0
  52. package/dist/player-core/highlighter.d.ts.map +1 -0
  53. package/dist/player-core/highlighter.js +103 -0
  54. package/dist/player-core/highlighter.js.map +1 -0
  55. package/dist/player-core/index.d.ts +17 -0
  56. package/dist/player-core/index.d.ts.map +1 -0
  57. package/dist/player-core/index.js +24 -0
  58. package/dist/player-core/index.js.map +1 -0
  59. package/dist/player-core/media-url.d.ts +18 -0
  60. package/dist/player-core/media-url.d.ts.map +1 -0
  61. package/dist/player-core/media-url.js +33 -0
  62. package/dist/player-core/media-url.js.map +1 -0
  63. package/dist/player-core/player.d.ts +9 -0
  64. package/dist/player-core/player.d.ts.map +1 -0
  65. package/dist/player-core/player.js +622 -0
  66. package/dist/player-core/player.js.map +1 -0
  67. package/dist/player-core/registry.d.ts +20 -0
  68. package/dist/player-core/registry.d.ts.map +1 -0
  69. package/dist/player-core/registry.js +31 -0
  70. package/dist/player-core/registry.js.map +1 -0
  71. package/dist/player-core/seek-delegate.d.ts +24 -0
  72. package/dist/player-core/seek-delegate.d.ts.map +1 -0
  73. package/dist/player-core/seek-delegate.js +64 -0
  74. package/dist/player-core/seek-delegate.js.map +1 -0
  75. package/dist/player-core/storage.d.ts +38 -0
  76. package/dist/player-core/storage.d.ts.map +1 -0
  77. package/dist/player-core/storage.js +107 -0
  78. package/dist/player-core/storage.js.map +1 -0
  79. package/dist/player-core/strings.d.ts +53 -0
  80. package/dist/player-core/strings.d.ts.map +1 -0
  81. package/dist/player-core/strings.js +45 -0
  82. package/dist/player-core/strings.js.map +1 -0
  83. package/dist/player-core/timings.d.ts +56 -0
  84. package/dist/player-core/timings.d.ts.map +1 -0
  85. package/dist/player-core/timings.js +90 -0
  86. package/dist/player-core/timings.js.map +1 -0
  87. package/dist/rehype/audio-words.d.ts +9 -3
  88. package/dist/rehype/audio-words.d.ts.map +1 -1
  89. package/dist/rehype/audio-words.js +17 -9
  90. package/dist/rehype/audio-words.js.map +1 -1
  91. package/dist/rehype/index.d.ts +2 -2
  92. package/dist/rehype/index.d.ts.map +1 -1
  93. package/dist/rehype/index.js.map +1 -1
  94. package/dist/rehype/rehype-math-speech.d.ts.map +1 -1
  95. package/dist/rehype/rehype-math-speech.js +2 -0
  96. package/dist/rehype/rehype-math-speech.js.map +1 -1
  97. package/dist/styles/content.css +41 -0
  98. package/dist/styles/layers.css +13 -0
  99. package/dist/styles/player.css +517 -0
  100. package/dist/styles/preset-shadcn.css +31 -0
  101. package/dist/styles/tokens.css +266 -0
  102. package/dist/styles/vocasync.css +10 -0
  103. package/dist/sync/index.d.ts +1 -1
  104. package/dist/sync/index.d.ts.map +1 -1
  105. package/dist/sync/index.js +1 -1
  106. package/dist/sync/index.js.map +1 -1
  107. package/dist/sync/orchestrator.d.ts.map +1 -1
  108. package/dist/sync/orchestrator.js +101 -47
  109. package/dist/sync/orchestrator.js.map +1 -1
  110. package/dist/types/index.d.ts +19 -5
  111. package/dist/types/index.d.ts.map +1 -1
  112. package/package.json +39 -17
  113. package/src/api/index.ts +4 -4
  114. package/src/components/AudioPlayer.astro +305 -1141
  115. package/src/components/index.ts +19 -34
  116. package/src/components/types.ts +140 -0
  117. package/src/config/index.ts +29 -24
  118. package/src/config/languages.ts +171 -0
  119. package/src/config/schema.ts +47 -24
  120. package/src/core/content-loader.ts +1 -1
  121. package/src/core/index.ts +7 -7
  122. package/src/env.d.ts +2 -0
  123. package/src/index.ts +23 -28
  124. package/src/integration.ts +66 -4
  125. package/src/player-core/boot.ts +62 -0
  126. package/src/player-core/highlighter.ts +159 -0
  127. package/src/player-core/index.ts +45 -0
  128. package/src/player-core/media-url.ts +35 -0
  129. package/src/player-core/player.ts +725 -0
  130. package/src/player-core/registry.ts +40 -0
  131. package/src/player-core/seek-delegate.ts +92 -0
  132. package/src/player-core/storage.ts +112 -0
  133. package/src/player-core/strings.ts +89 -0
  134. package/src/player-core/timings.ts +115 -0
  135. package/src/rehype/audio-words.ts +25 -12
  136. package/src/rehype/index.ts +2 -3
  137. package/src/rehype/rehype-math-speech.ts +3 -1
  138. package/src/styles/content.css +41 -0
  139. package/src/styles/layers.css +13 -0
  140. package/src/styles/player.css +517 -0
  141. package/src/styles/preset-shadcn.css +31 -0
  142. package/src/styles/tokens.css +266 -0
  143. package/src/styles/vocasync.css +10 -0
  144. package/src/sync/index.ts +1 -1
  145. package/src/sync/orchestrator.ts +120 -56
  146. package/src/types/index.ts +19 -5
  147. package/dist/styles/variables.css +0 -164
  148. package/src/styles/variables.css +0 -164
package/README.md CHANGED
@@ -7,9 +7,12 @@ Turn your Astro blog posts into narrated audio with word-level synchronization.
7
7
  - 🎙️ **Text-to-Speech Synthesis** - Generate natural-sounding audio narration for your content
8
8
  - 🎯 **Word-Level Alignment** - Precise timestamps for every word, powered by forced alignment
9
9
  - ✨ **Live Word Highlighting** - Karaoke-style highlighting that follows along with playback
10
- - 🎛️ **Built-in Audio Player** - Accessible player with keyboard shortcuts and mini-player mode
11
- - 🌍 **14 Languages** - Global reach with support for 14 languages
12
- - 🎨 **Fully Themeable** - CSS variables for seamless integration with any design
10
+ - 🎛️ **Built-in Audio Player** - Keyboard shortcuts, a floating dock, and controls you can reorder or replace
11
+ - 🌍 **57 languages narrated, 13 highlighted** - Skip alignment with `align: false` and any language the voices speak is available
12
+ - 🎨 **Themeable down to the pixel** - Four seeds carry a whole theme; every rule loses to yours, so no `!important`
13
+ - 🌗 **Dark mode that follows yours** - The OS preference plus `.dark`, `[data-theme]` and `[data-mode]`, with no configuration
14
+ - 🈯 **Translatable** - Every visible string and accessible label is overridable
15
+ - 🧩 **Headless option** - Import the engine and bring your own markup
13
16
 
14
17
  ## Demo
15
18
 
@@ -23,13 +26,17 @@ Turn your Astro blog posts into narrated audio with word-level synchronization.
23
26
  - [Quick Start](#quick-start)
24
27
  - [Project Structure](#project-structure)
25
28
  - [Configuration](#configuration)
29
+ - [Integration options](#integration-options)
26
30
  - [CLI Commands](#cli-commands)
27
31
  - [Components](#components)
32
+ - [Headless usage](#headless-usage)
28
33
  - [Supported Languages](#supported-languages)
29
34
  - [Math Support](#math-support)
30
35
  - [Deployment](#deployment)
31
36
  - [Important: Audio Map](#important-audio-map)
32
- - [Customizing Styles](#customizing-styles)
37
+ - [Theming](#theming)
38
+ - [Migrating from v1](#migrating-from-v1)
39
+ - [Troubleshooting](#troubleshooting)
33
40
 
34
41
  ## Installation
35
42
 
@@ -41,6 +48,18 @@ bun add @vocasync/astro
41
48
  pnpm add @vocasync/astro
42
49
  ```
43
50
 
51
+ ### Astro 7
52
+
53
+ Astro 7 no longer installs `@astrojs/markdown-remark` by default, and the rehype
54
+ plugins that produce word highlighting cannot run without it:
55
+
56
+ ```bash
57
+ bun add @astrojs/markdown-remark
58
+ ```
59
+
60
+ Astro 4, 5 and 6 need nothing extra. The plugin is tested against all four on every
61
+ change.
62
+
44
63
  ## Quick Start
45
64
 
46
65
  ### 1. Create VocaSync Config
@@ -123,16 +142,31 @@ const audioEntry = audioMap.entries[post.slug];
123
142
  ---
124
143
 
125
144
  <article>
126
- <!-- Audio player at the top -->
127
- <AudioPlayer slug={post.slug} audioEntry={audioEntry} label="Listen to this post" />
128
-
129
- <!-- Article content - must have data-article-body for word highlighting -->
145
+ <AudioPlayer slug={post.slug} audioEntry={audioEntry} />
146
+
147
+ <!-- Word highlighting needs a root to find the spans in -->
130
148
  <div data-article-body>
131
149
  <slot />
132
150
  </div>
133
151
  </article>
134
152
  ```
135
153
 
154
+ ### 7. Make it look like your site
155
+
156
+ The player is styled by four CSS custom properties. Point them at tokens you already
157
+ have and it adopts your palette and your dark mode:
158
+
159
+ ```css
160
+ :root {
161
+ --vocasync-accent: var(--color-primary);
162
+ --vocasync-surface: var(--color-card);
163
+ --vocasync-text: var(--color-text);
164
+ }
165
+ ```
166
+
167
+ There is a lot more available — variants, control ordering, slots, translation — see
168
+ [Theming](#theming) and [Components](#components). Nothing needs `!important`.
169
+
136
170
  ## Project Structure
137
171
 
138
172
  After setup, your project should look like this:
@@ -156,6 +190,33 @@ my-astro-site/
156
190
 
157
191
  ## Configuration
158
192
 
193
+ ### Integration options
194
+
195
+ `vocasync()` takes an options object in `astro.config.mjs`. Everything about *content*
196
+ lives in `vocasync.config.mjs` below; these are about the integration itself.
197
+
198
+ ```javascript
199
+ integrations: [
200
+ vocasync({
201
+ // Inject the player stylesheet on every page. Set false to import it yourself:
202
+ // `@vocasync/astro/styles/vocasync.css`, or just `content.css` when you drive the
203
+ // engine headlessly and ship your own chrome.
204
+ styles: true,
205
+
206
+ theme: {
207
+ // A selector your site already uses for dark mode. Usually unnecessary --
208
+ // `.dark`, `[data-theme="dark"]` and `[data-mode="dark"]` are recognised out of
209
+ // the box, covering Tailwind, next-themes, daisyUI and Starlight.
210
+ darkSelector: '[data-appearance="night"]',
211
+ },
212
+ }),
213
+ ]
214
+ ```
215
+
216
+ The integration does **not** register the rehype plugins. Add `rehypeAudioWords` (and
217
+ `rehypeMathSpeech` if you use maths) to `markdown.rehypePlugins` yourself — their order
218
+ relative to your maths renderer matters, so it is left explicit.
219
+
159
220
  ### vocasync.config.mjs
160
221
 
161
222
  Full configuration options:
@@ -201,6 +262,10 @@ export default {
201
262
  concurrency: 3, // Parallel jobs (1-10)
202
263
  force: false, // Force reprocessing
203
264
  },
265
+
266
+ // Produce word-level timings. Off means narration only: cheaper, and any of the 57
267
+ // synthesis languages rather than the 13 that can be aligned.
268
+ align: true,
204
269
  };
205
270
  ```
206
271
 
@@ -220,7 +285,19 @@ Bonjour…
220
285
  ```
221
286
 
222
287
  Invalid values are skipped with a warning. Changing any of these re-syncs the post
223
- (the change-detection hash includes the resolved voice/language/format).
288
+ (the change-detection hash includes the resolved voice, language, format and
289
+ `align`).
290
+
291
+ `align: false` in a post's frontmatter narrates that post without word timings, which
292
+ also lets it use a language outside the aligned set:
293
+
294
+ ```yaml
295
+ ---
296
+ title: "ประกาศ"
297
+ language: th
298
+ align: false
299
+ ---
300
+ ```
224
301
 
225
302
  ### Rehype Plugin Options
226
303
 
@@ -229,7 +306,7 @@ Invalid values are skipped with a warning. Changing any of these re-syncs the po
229
306
  [rehypeAudioWords, {
230
307
  collectionName: "blog", // Content collection name
231
308
  audioMapPath: "src/data/audio-map.json", // Path to audio map
232
- classPrefix: "vocasync", // CSS class prefix (default: "vocasync")
309
+ extraWordClass: "prose-word", // optional extra class on each word span
233
310
  }]
234
311
  ```
235
312
 
@@ -274,90 +351,341 @@ npx vocasync help
274
351
 
275
352
  ### AudioPlayer
276
353
 
277
- The main audio player component with word highlighting support.
278
-
279
354
  ```astro
280
355
  ---
281
356
  import AudioPlayer from "@vocasync/astro/components/AudioPlayer.astro";
357
+ import audioMap from "../data/audio-map.json";
282
358
  ---
283
359
 
284
- <AudioPlayer
285
- slug={post.slug}
286
- label="Listen to this post"
287
- articleSelector="[data-article-body]"
288
- enableHighlighting={true}
289
- enableClickToSeek={true}
290
- enableMiniPlayer={true}
291
- trailLength={4}
292
- />
360
+ <AudioPlayer slug={slug} audioEntry={audioMap.entries[slug]} />
361
+
362
+ <div data-article-body>
363
+ <Content />
364
+ </div>
293
365
  ```
294
366
 
367
+ The player renders markup only. Playback, highlighting and the view-transition
368
+ lifecycle live in a module script that is bundled once per page, no matter how many
369
+ players are on it.
370
+
295
371
  #### Props
296
372
 
297
373
  | Prop | Type | Default | Description |
298
374
  |------|------|---------|-------------|
299
- | `slug` | `string` | required | Post slug to lookup audio |
300
- | `audioEntry` | `object` | `undefined` | Audio entry from audio-map.json (`audioUrl`, `synthesisPublishableKey`, `words`, `duration`) |
301
- | `label` | `string` | `"Listen to this article"` | Accessible label |
302
- | `showPlaceholder` | `boolean` | `true` | Show message when no audio |
303
- | `class` | `string` | `""` | Additional CSS classes |
304
- | `articleSelector` | `string` | `"[data-article-body]"` | Selector for word highlighting container |
305
- | `enableMiniPlayer` | `boolean` | `true` | Show floating mini player on scroll |
306
- | `enableHighlighting` | `boolean` | `true` | Enable word highlighting |
307
- | `enableClickToSeek` | `boolean` | `true` | Enable click on words to seek audio |
308
- | `trailLength` | `number` | `4` | Number of trailing highlighted words |
375
+ | `slug` | `string` | required | Post slug, used to look up audio |
376
+ | `audioEntry` | `AudioEntry` | — | Entry from `audio-map.json` |
377
+ | `variant` | `"bar" \| "minimal" \| "card"` | `"bar"` | Shape of the player |
378
+ | `size` | `"sm" \| "md" \| "lg"` | `"md"` | Scales the whole player |
379
+ | `controls` | `ControlName[]` | see below | Which controls render, and in what order |
380
+ | `speeds` | `number[]` | `[0.5, 0.75, 1, 1.25, 1.5, 2]` | Playback rates in the speed menu |
381
+ | `skipSeconds` | `number` | `15` | How far the skip controls and arrow keys jump |
382
+ | `strings` | `Partial<PlayerStrings>` | English | Every visible string and accessible label |
383
+ | `articleSelector` | `string` | `"[data-article-body]"` | Element containing the word spans |
384
+ | `highlight` | `HighlightOptions` | `{}` | `{ enabled, trailLength, clickToSeek }` |
385
+ | `dock` | `DockOptions` | `{}` | `{ enabled }` — the floating player |
386
+ | `autoScroll` | `"off" \| "paragraph"` | `"off"` | Scroll the spoken paragraph into view |
387
+ | `exclusive` | `boolean` | `true` | Starting this player pauses the others |
388
+ | `rememberPreferences` | `boolean` | `true` | Persist speed, volume, mute and highlighting |
389
+ | `rememberPosition` | `boolean` | `false` | Resume where the reader left off, keyed by `slug` |
390
+ | `mediaSession` | `boolean` | `true` | Publish to the OS media controls |
391
+ | `title` | `string` | — | Title for the OS media controls |
392
+ | `artwork` | `string` | — | Artwork URL for the OS media controls |
393
+ | `showPlaceholder` | `boolean` | `true` | Show a message when there is no audio |
394
+ | `class` | `string` | `""` | Extra classes on the root |
395
+ | `id` | `string` | derived | Overrides the generated element id |
396
+
397
+ #### Controls, and their order
398
+
399
+ `controls` sets both which controls appear and where they sit:
309
400
 
310
- #### Keyboard Shortcuts
401
+ ```astro
402
+ <AudioPlayer slug={slug} controls={["play", "volume", "progress", "highlight"]} />
403
+ ```
311
404
 
312
- When the player is focused (click on it or Tab to it), the following keyboard shortcuts are available:
405
+ | Name | Renders |
406
+ |------|---------|
407
+ | `play` | Play/pause button |
408
+ | `progress` | Elapsed/total time above the seek bar; grows to fill the row |
409
+ | `time` | Elapsed/total time on its own |
410
+ | `highlight` | Word-highlighting toggle |
411
+ | `speed` | Playback-speed menu |
412
+ | `volume` | Mute button and volume slider |
413
+ | `skip-back` | Jump backwards by `skipSeconds` |
414
+ | `skip-forward` | Jump forwards by `skipSeconds` |
313
415
 
314
- | Key | Action |
315
- |-----|--------|
316
- | `Space` | Play/Pause |
317
- | `←` Left Arrow | Seek backward 5 seconds |
318
- | `→` Right Arrow | Seek forward 5 seconds |
319
- | `M` | Toggle mute |
320
- | `H` | Toggle word highlighting |
416
+ Default: `["play", "progress", "highlight", "speed", "volume"]`. Anything you leave out
417
+ is not rendered — pass `[]` with `dock={{ enabled: true }}` for a dock-only player.
418
+
419
+ #### Variants
420
+
421
+ `bar` is a horizontal strip on a card. `minimal` drops the background, border, shadow
422
+ and padding so the player borrows the page — useful inline with prose or under a title.
423
+ `card` opens room above the controls for a title or artwork through the `before` slot.
424
+
425
+ #### Slots
426
+
427
+ Every slot falls back to the shipped markup, so override only what you need.
428
+
429
+ | Slot | Replaces |
430
+ |------|----------|
431
+ | `icon-play`, `icon-pause` | Play/pause icons |
432
+ | `icon-volume`, `icon-muted` | Volume icons |
433
+ | `icon-highlight-on`, `icon-highlight-off` | Highlight-toggle icons |
434
+ | `icon-skip-back`, `icon-skip-forward` | Skip icons |
435
+ | `placeholder` | The "no audio" message |
436
+ | `error` | The failed-to-load message and its retry button |
437
+ | `before`, `after` | Arbitrary content above/below the controls |
438
+
439
+ ```astro
440
+ <AudioPlayer slug={slug} audioEntry={entry} variant="card">
441
+ <div slot="before"><strong>{title}</strong></div>
442
+ <svg slot="icon-play" class="vocasync-icon vocasync-icon--play" viewBox="0 0 24 24">
443
+ <path d="M8 5v14l11-7z" fill="currentColor" />
444
+ </svg>
445
+ </AudioPlayer>
446
+ ```
447
+
448
+ #### Text and translation
449
+
450
+ Every visible string and every `aria-label` comes from `strings`:
451
+
452
+ ```astro
453
+ <AudioPlayer
454
+ slug={slug}
455
+ audioEntry={entry}
456
+ strings={{
457
+ label: "Écouter cet article",
458
+ play: "Lire",
459
+ pause: "Pause",
460
+ unavailable: "Audio non disponible pour cet article",
461
+ }}
462
+ />
463
+ ```
464
+
465
+ Every key is a plain string, and anything you omit keeps its English default.
466
+
467
+ | Key | Default | Notes |
468
+ |-----|---------|-------|
469
+ | `label` | `Listen to this article` | Names the player region; also the media-session title fallback |
470
+ | `loading` | `Loading audio…` | |
471
+ | `unavailable` | `Audio not available for this article` | No audio for this post |
472
+ | `error` | `Audio could not be loaded` | Audio exists but failed |
473
+ | `retry` | `Try again` | |
474
+ | `play` / `pause` | `Play` / `Pause` | |
475
+ | `seek` | `Seek` | |
476
+ | `seekPosition` | `{current} of {total}` | Announced by the seek slider; placeholders are spoken durations |
477
+ | `mute` / `unmute` | `Mute` / `Unmute` | |
478
+ | `volume` | `Volume` | |
479
+ | `speed` | `Playback speed` | |
480
+ | `speedValue` | `{rate}x` | Each entry in the speed menu |
481
+ | `highlightOn` / `highlightOff` | `Disable…` / `Enable word highlighting` | |
482
+ | `skipBack` / `skipForward` | `Back {seconds} seconds` / `Forward {seconds} seconds` | |
483
+
484
+ Placeholders in `{braces}` are substituted at render time. An unrecognised one is left
485
+ visible rather than blanked, so a typo in a translation shows up instead of quietly
486
+ disappearing — which matters when the string is an accessible label nobody sees.
487
+
488
+ ### Remembering what the reader chose
489
+
490
+ Speed, volume, mute and the highlighting toggle persist across pages and visits by
491
+ default — set `rememberPreferences={false}` to opt out. `rememberPosition` is separate
492
+ and off by default: resuming is welcome on a long article and confusing on a short post
493
+ someone expects to start from the beginning. When on, a position is only restored if
494
+ the reader was more than five seconds in and more than ten seconds from the end, and it
495
+ is cleared once the audio finishes.
496
+
497
+ All of it degrades quietly. `localStorage` throws outright in browsers configured to
498
+ block site data, and stored values are validated before use — a hand-edited playback
499
+ rate is not assigned to the media element.
500
+
501
+ ### Loading and failure states
502
+
503
+ The player root carries `data-player-state` (`loading`, `ready`, `no-audio`, `error`)
504
+ and `data-player-buffering` while the media element is waiting on the network. They are
505
+ distinct on purpose: a slow connection should not look like a broken one. Both are
506
+ styleable:
507
+
508
+ ```css
509
+ :root:has(.vocasync-player[data-player-buffering]) { /* … */ }
510
+ ```
511
+
512
+ The seek bar also paints its buffered range, driven by `--vocasync-played` and
513
+ `--vocasync-buffered`.
321
514
 
322
- #### Highlighting Toggle
515
+ #### Events
323
516
 
324
- The player includes a highlighter icon button that allows users to toggle word highlighting on/off during playback. This is useful for users who find the highlighting distracting or prefer to just listen.
517
+ The root element dispatches bubbling `CustomEvent`s, so you can hook analytics or
518
+ build your own UI alongside the player without forking it:
325
519
 
326
- #### Click-to-Seek
520
+ `vocasync:ready`, `vocasync:play`, `vocasync:pause`, `vocasync:ended`,
521
+ `vocasync:error`, `vocasync:ratechange`, `vocasync:wordchange`.
327
522
 
328
- When `enableClickToSeek` is enabled (default), clicking on any word in the article will:
329
- 1. Seek the audio to that word's timestamp
330
- 2. Start playback if paused
523
+ ```js
524
+ document.querySelector(".vocasync-player")
525
+ .addEventListener("vocasync:wordchange", (e) => {
526
+ // e.detail is { index, el } or null during silence between words
527
+ });
528
+ ```
529
+
530
+ #### Keyboard shortcuts
331
531
 
332
- This is useful for jumping to specific parts of an article. Disable it with `enableClickToSeek={false}` if you prefer words to not be interactive.
532
+ Available when focus is inside the player.
533
+
534
+ | Key | Action |
535
+ |-----|--------|
536
+ | `Space` | Play/pause |
537
+ | `←` / `→` | Skip by `skipSeconds` (default 15) |
538
+ | `M` | Toggle mute |
539
+ | `H` | Toggle word highlighting |
540
+ | `Esc` | Close the speed menu |
541
+
542
+ Inside the speed menu, `↑`/`↓`, `Home` and `End` move between rates and `Esc` returns
543
+ focus to the trigger.
333
544
 
334
545
  ### Word Highlighting
335
546
 
336
- For word highlighting to work, wrap your article content with `data-article-body`:
547
+ Wrap your article content so the player can find the word spans:
337
548
 
338
549
  ```astro
339
550
  <div data-article-body>
340
- <Content /> <!-- Your markdown content -->
551
+ <Content />
341
552
  </div>
342
553
  ```
343
554
 
344
- The rehype plugin wraps each word in a `<span>` with timing data at build time.
555
+ The rehype plugin wraps each word in a `<span class="vocasync-word" data-i data-n>` at
556
+ build time. `data-i` is the word's start index in the alignment stream and `data-n` is
557
+ how many alignment tokens it consumes — a visible word can span several, since "$50" is
558
+ spoken as two.
559
+
560
+ Clicking a word seeks to it. That is independent of the highlighting toggle, so a
561
+ reader who turns highlighting off keeps click-to-seek.
562
+
563
+ ## Headless usage
564
+
565
+ If you want entirely your own markup, import the engine and skip the component. This
566
+ API is covered by semver from 2.0.0.
567
+
568
+ ```ts
569
+ import { createPlayer } from "@vocasync/astro/player-core";
570
+
571
+ const player = createPlayer(document.querySelector(".my-player"));
572
+ // player.pause(); player.destroy();
573
+ ```
574
+
575
+ `createPlayer` reads its configuration from a
576
+ `<script type="application/json" class="vocasync-data">` inside the element, and finds
577
+ controls by `data-action` and `data-state` attributes — see the shipped component for
578
+ the shape it expects.
579
+
580
+ Lower-level pieces are exported too, for building something quite different:
581
+
582
+ ```ts
583
+ import {
584
+ computeSpanTimings, // visible units -> time spans
585
+ spanAtTime, // the span active at t, or null during silence
586
+ idxForTime,
587
+ createHighlighter,
588
+ resolveAudioSrc,
589
+ } from "@vocasync/astro/player-core";
590
+ ```
591
+
592
+ Headless consumers still need `content.css` for the word-highlighting styles, but can
593
+ skip `player.css`:
594
+
595
+ ```css
596
+ @import "@vocasync/astro/styles/content.css";
597
+ ```
345
598
 
346
599
  ## Supported Languages
347
600
 
348
- VocaSync supports 14 languages where both speech synthesis and forced alignment are available. Languages use ISO 639-1 codes:
601
+ There are two lists, and which one applies depends on whether you want word
602
+ highlighting.
603
+
604
+ **Narration** works in all 57 languages the synthesis voices speak.
605
+
606
+ **Word highlighting and click-to-seek** need forced alignment, which covers 13 of them.
607
+ Alignment is what produces the per-word timings; without it there is nothing to
608
+ highlight or seek to.
609
+
610
+ So a post in Thai or Hindi can be narrated — it just cannot be highlighted:
349
611
 
350
- | Code | Language | Code | Language |
351
- |------|----------|------|----------|
352
- | `zh` | Chinese | `pl` | Polish |
353
- | `cs` | Czech | `pt` | Portuguese |
354
- | `en` | English | `ru` | Russian |
355
- | `fr` | French | `es` | Spanish |
356
- | `de` | German | `sv` | Swedish |
357
- | `ja` | Japanese | `tr` | Turkish |
358
- | `ko` | Korean | `uk` | Ukrainian |
612
+ ```javascript
613
+ // vocasync.config.mjs
614
+ export default {
615
+ collection: { name: "blog", path: "./src/content/blog" },
616
+ language: "th",
617
+ align: false, // narration only; skips alignment
618
+ };
619
+ ```
359
620
 
360
- > **Note:** VocaSync requires both speech synthesis and word-level forced alignment for each language. While synthesis (powered by OpenAI TTS) supports 61 languages, alignment (powered by Montreal Forced Aligner) is available for a smaller set. The 14 languages listed above are where both capabilities overlap, and they match the platform's alignment-supported set.
621
+ Set `align: false` in a single post's frontmatter to make the exception there instead.
622
+ Asking for a language that cannot align while `align` is on is rejected before any
623
+ synthesis is paid for, with a message naming the language and what to do about it.
624
+
625
+ | Code | Language | Highlighting |
626
+ |------|----------|--------------|
627
+ | `af` | Afrikaans | — |
628
+ | `ar` | Arabic | — |
629
+ | `hy` | Armenian | — |
630
+ | `az` | Azerbaijani | — |
631
+ | `be` | Belarusian | — |
632
+ | `bs` | Bosnian | — |
633
+ | `bg` | Bulgarian | — |
634
+ | `ca` | Catalan | — |
635
+ | `zh` | Chinese | ✅ |
636
+ | `hr` | Croatian | — |
637
+ | `cs` | Czech | ✅ |
638
+ | `da` | Danish | — |
639
+ | `nl` | Dutch | — |
640
+ | `en` | English | ✅ |
641
+ | `et` | Estonian | — |
642
+ | `fi` | Finnish | — |
643
+ | `fr` | French | ✅ |
644
+ | `gl` | Galician | — |
645
+ | `de` | German | ✅ |
646
+ | `el` | Greek | — |
647
+ | `he` | Hebrew | — |
648
+ | `hi` | Hindi | — |
649
+ | `hu` | Hungarian | — |
650
+ | `is` | Icelandic | — |
651
+ | `id` | Indonesian | — |
652
+ | `it` | Italian | — |
653
+ | `ja` | Japanese | ✅ |
654
+ | `kn` | Kannada | — |
655
+ | `kk` | Kazakh | — |
656
+ | `ko` | Korean | — |
657
+ | `lv` | Latvian | — |
658
+ | `lt` | Lithuanian | — |
659
+ | `mk` | Macedonian | — |
660
+ | `ms` | Malay | — |
661
+ | `mi` | Maori | — |
662
+ | `mr` | Marathi | — |
663
+ | `ne` | Nepali | — |
664
+ | `no` | Norwegian | — |
665
+ | `fa` | Persian | — |
666
+ | `pl` | Polish | ✅ |
667
+ | `pt` | Portuguese | ✅ |
668
+ | `ro` | Romanian | — |
669
+ | `ru` | Russian | ✅ |
670
+ | `sr` | Serbian | — |
671
+ | `sk` | Slovak | — |
672
+ | `sl` | Slovenian | — |
673
+ | `es` | Spanish | ✅ |
674
+ | `sw` | Swahili | — |
675
+ | `sv` | Swedish | ✅ |
676
+ | `tl` | Tagalog | — |
677
+ | `ta` | Tamil | — |
678
+ | `th` | Thai | — |
679
+ | `tr` | Turkish | ✅ |
680
+ | `uk` | Ukrainian | ✅ |
681
+ | `ur` | Urdu | — |
682
+ | `vi` | Vietnamese | — |
683
+ | `cy` | Welsh | — |
684
+
685
+ > **Korean** was withdrawn from alignment in September 2026. It still synthesises;
686
+ > pass `align: false` to use it.
687
+
688
+ Turning alignment off also costs less, since it is a second job on top of synthesis.
361
689
 
362
690
  ## Math Support
363
691
 
@@ -564,56 +892,370 @@ Add your `.env` file to `.gitignore`:
564
892
  .env.local
565
893
  ```
566
894
 
567
- ## Customizing Styles
895
+ ## Theming
896
+
897
+ The player is designed to disappear into your site. Every visual decision is a CSS
898
+ custom property, and every rule it ships sits in a cascade layer *and* is wrapped in
899
+ `:where()` — so it has zero specificity and any rule you write beats it, whatever your
900
+ import order. You should never need `!important`.
901
+
902
+ The stylesheet is injected for you. Pass `styles: false` to the integration if you
903
+ would rather import it yourself.
568
904
 
569
- Override CSS variables to match your theme:
905
+ ### Start with four seeds
570
906
 
571
907
  ```css
572
908
  :root {
573
- /* Player colors */
574
- --vocasync-primary: #3b82f6;
575
- --vocasync-primary-content: white;
576
- --vocasync-surface: #f8fafc;
577
- --vocasync-border: #e2e8f0;
578
- --vocasync-text: #1e293b;
579
- --vocasync-text-muted: #64748b;
580
-
581
- /* Word highlighting */
582
- --vocasync-highlight: #10b981;
583
- --vocasync-highlight-text: white;
584
- --vocasync-highlight-active-opacity: 0.25;
585
- --vocasync-highlight-trail-opacity: 0.12;
909
+ --vocasync-accent: #7c3aed;
910
+ --vocasync-surface: #ffffff;
911
+ --vocasync-text: #1e1b2e;
912
+ --vocasync-highlight: #f59e0b;
586
913
  }
914
+ ```
587
915
 
588
- /* Dark mode */
589
- @media (prefers-color-scheme: dark) {
590
- :root {
591
- --vocasync-surface: #1e293b;
592
- --vocasync-border: #334155;
593
- --vocasync-text: #f1f5f9;
594
- --vocasync-text-muted: #94a3b8;
595
- }
916
+ Borders, muted text, hover states, the track behind the progress bar and the contrast
917
+ colour on the play button all derive from those four. Override any derived token on
918
+ its own if a derivation is not what you wanted.
919
+
920
+ ### Better: point them at tokens you already have
921
+
922
+ ```css
923
+ :root {
924
+ --vocasync-accent: var(--color-primary);
925
+ --vocasync-surface: var(--color-card);
926
+ --vocasync-text: var(--color-text);
596
927
  }
597
928
  ```
598
929
 
930
+ Now the player follows your palette *and* your dark mode, because your tokens already
931
+ flip. For shadcn/ui and Tailwind that is a single import:
932
+
933
+ ```css
934
+ @import "@vocasync/astro/styles/preset-shadcn.css";
935
+ ```
936
+
937
+ ### Dark mode
938
+
939
+ Recognised with no configuration: the OS preference, plus `.dark`,
940
+ `[data-theme="dark"]` and `[data-mode="dark"]` — which covers Tailwind, next-themes,
941
+ daisyUI and Starlight. An explicit `.light`, `[data-theme="light"]` or
942
+ `data-vocasync-scheme="light"` opts out of the OS preference.
943
+
944
+ If your site signals dark mode some other way, name the selector:
945
+
946
+ ```js
947
+ vocasync({ theme: { darkSelector: '[data-appearance="night"]' } })
948
+ ```
949
+
950
+ ### Token reference
951
+
952
+ **Colour — seeds**
953
+
954
+ | Token | Default | Notes |
955
+ |-------|---------|-------|
956
+ | `--vocasync-accent` | `#3b82f6` | Play button, progress fill, slider thumbs |
957
+ | `--vocasync-surface` | `#f8fafc` | Player background |
958
+ | `--vocasync-text` | `#1e293b` | Primary text |
959
+ | `--vocasync-highlight` | `#10b981` | The word currently being spoken |
960
+
961
+ These four are registered with `@property`, so assigning something that is not a colour
962
+ falls back instead of blanking the component.
963
+
964
+ **Colour — derived** (override individually if you want)
965
+
966
+ | Token | Derived from |
967
+ |-------|--------------|
968
+ | `--vocasync-accent-hover` | accent, darkened |
969
+ | `--vocasync-accent-content` | black or white, whichever reads on the accent |
970
+ | `--vocasync-surface-raised` | surface, lightened — menus and the dock |
971
+ | `--vocasync-text-muted` | text mixed toward surface |
972
+ | `--vocasync-text-faint` | text mixed further toward surface |
973
+ | `--vocasync-border` | text mixed heavily toward surface |
974
+ | `--vocasync-track` | the unfilled part of a slider |
975
+ | `--vocasync-buffered-color` | the loaded-so-far range behind the seek bar |
976
+ | `--vocasync-highlight-active-bg` | highlight at 25% |
977
+ | `--vocasync-highlight-trail-bg` | highlight at 12% |
978
+ | `--vocasync-highlight-active-text` | unset — the active word keeps the prose colour |
979
+ | `--vocasync-l-threshold` | `0.623` — lightness at which `accent-content` flips to black. Perceptual, not a WCAG measurement; raise it if your accent needs dark text sooner |
980
+
981
+ **Typography**
982
+
983
+ | Token | Default |
984
+ |-------|---------|
985
+ | `--vocasync-font-family` | `inherit` |
986
+ | `--vocasync-font-size` | `0.875rem` |
987
+ | `--vocasync-font-size-sm` | `0.75rem` |
988
+ | `--vocasync-font-weight` | `400` |
989
+ | `--vocasync-font-weight-medium` | `500` |
990
+ | `--vocasync-line-height` | `1.4` |
991
+ | `--vocasync-numeric` | `tabular-nums` |
992
+
993
+ **Density and size** — `--vocasync-density` multiplies all of the following, so one
994
+ value rescales the player. The `size` prop sets it per player.
995
+
996
+ | Token | Default |
997
+ |-------|---------|
998
+ | `--vocasync-density` | `1` |
999
+ | `--vocasync-unit` | `0.25rem` |
1000
+ | `--vocasync-gap` | `0.75rem` |
1001
+ | `--vocasync-gap-sm` | `0.25rem` |
1002
+ | `--vocasync-padding` | `1rem` |
1003
+ | `--vocasync-control-size` | `2.5rem` |
1004
+ | `--vocasync-control-size-sm` | `2rem` |
1005
+ | `--vocasync-icon-size` | `1.25rem` |
1006
+
1007
+ **Shape**
1008
+
1009
+ | Token | Default |
1010
+ |-------|---------|
1011
+ | `--vocasync-radius` | `0.75rem` |
1012
+ | `--vocasync-radius-control` | `0.375rem` |
1013
+ | `--vocasync-radius-menu` | `0.5rem` |
1014
+ | `--vocasync-radius-pill` | `9999px` |
1015
+ | `--vocasync-word-radius` | `0.125rem` |
1016
+ | `--vocasync-border-width` | `1px` |
1017
+
1018
+ **Sliders, dock, focus, elevation, motion, layering**
1019
+
1020
+ | Token | Default |
1021
+ |-------|---------|
1022
+ | `--vocasync-slider-height` | `0.375rem` |
1023
+ | `--vocasync-played` | runtime state — the played range, written by the player |
1024
+ | `--vocasync-buffered` | runtime state — the loaded range, written by the player |
1025
+ | `--vocasync-slider-thumb-size` | `1rem` |
1026
+ | `--vocasync-volume-width` | `4rem` |
1027
+ | `--vocasync-dock-height` | `3.5rem` |
1028
+ | `--vocasync-dock-offset` | `1rem` |
1029
+ | `--vocasync-dock-width` | `20rem` |
1030
+ | `--vocasync-focus-width` | `2px` |
1031
+ | `--vocasync-focus-offset` | `2px` |
1032
+ | `--vocasync-focus-color` | `var(--vocasync-accent)` |
1033
+ | `--vocasync-shadow-sm`, `--vocasync-shadow`, `--vocasync-shadow-lg` | subtle elevation |
1034
+ | `--vocasync-transition-fast`, `--vocasync-transition` | `150ms` / `200ms` ease |
1035
+ | `--vocasync-menu-z` | `10` |
1036
+ | `--vocasync-dock-z` | `1000` |
1037
+
1038
+ ### Stylesheets
1039
+
1040
+ | Import | Contains |
1041
+ |--------|----------|
1042
+ | `@vocasync/astro/styles/vocasync.css` | Everything (what the integration injects) |
1043
+ | `@vocasync/astro/styles/layers.css` | The `@layer` order statement only |
1044
+ | `@vocasync/astro/styles/tokens.css` | The tokens above |
1045
+ | `@vocasync/astro/styles/content.css` | Word highlighting — needed even when headless |
1046
+ | `@vocasync/astro/styles/player.css` | The player chrome — skip it if you bring your own |
1047
+ | `@vocasync/astro/styles/preset-shadcn.css` | Maps our tokens onto a shadcn host's |
1048
+
1049
+ Import `layers.css` first if you want the layer order pinned regardless of where your
1050
+ other imports land.
1051
+
1052
+ ## Migrating from v1
1053
+
1054
+ **Your audio map is unchanged.** The schema stays at version 3, so there is no re-sync
1055
+ and no API spend — this release is presentation only.
1056
+
1057
+ ### Why the styling changed
1058
+
1059
+ Astro compiles a component's scoped styles to `.vocasync-player[data-astro-cid-…]`,
1060
+ which has higher specificity than a plain class. Your own `.vocasync-player { … }` lost
1061
+ to it, and so did any Tailwind utility passed through `class`. Three `!important`
1062
+ declarations closed the rest. In practice the player could not be restyled.
1063
+
1064
+ The CSS now ships as ordinary stylesheets, in a cascade layer, with every selector
1065
+ wrapped in `:where()`. Your rules win — layered or not, in any import order — and
1066
+ nothing needs `!important`.
1067
+
1068
+ ### Stylesheet import
1069
+
1070
+ ```diff
1071
+ - import "@vocasync/astro/styles/variables.css";
1072
+ ```
1073
+
1074
+ Delete it. The integration injects the stylesheet; pass `styles: false` if you would
1075
+ rather import `@vocasync/astro/styles/vocasync.css` yourself.
1076
+
1077
+ ### Token renames
1078
+
1079
+ | v1 | v2 |
1080
+ |----|----|
1081
+ | `--vocasync-primary` | `--vocasync-accent` |
1082
+ | `--vocasync-primary-hover` | `--vocasync-accent-hover` |
1083
+ | `--vocasync-primary-content` | `--vocasync-accent-content` |
1084
+ | `--vocasync-surface-elevated` | `--vocasync-surface-raised` |
1085
+ | `--vocasync-border-focus` | `--vocasync-focus-color` |
1086
+ | `--vocasync-player-radius` | `--vocasync-radius` |
1087
+ | `--vocasync-player-padding` | `--vocasync-padding` |
1088
+ | `--vocasync-player-gap` | `--vocasync-gap` |
1089
+ | `--vocasync-button-size` | `--vocasync-control-size` |
1090
+ | `--vocasync-button-radius` | `--vocasync-radius-pill` |
1091
+ | `--vocasync-slider-radius` | `--vocasync-radius-pill` |
1092
+ | `--vocasync-mini-height` | `--vocasync-dock-height` |
1093
+ | `--vocasync-mini-offset` | `--vocasync-dock-offset` |
1094
+ | `--vocasync-highlight-active-opacity` | `--vocasync-highlight-active-bg` (a colour, not a number) |
1095
+ | `--vocasync-highlight-trail-opacity` | `--vocasync-highlight-trail-bg` (a colour, not a number) |
1096
+ | `--vocasync-highlight-text` | **removed** |
1097
+ | `--vocasync-transition-slow` | **removed** |
1098
+
1099
+ `--vocasync-highlight-text` was documented but no rule ever read it, so setting it
1100
+ never did anything. `--vocasync-transition-slow` was never referenced.
1101
+
1102
+ In most cases you can delete the overrides entirely and set the four seeds instead.
1103
+
1104
+ ### Prop changes
1105
+
1106
+ | v1 | v2 |
1107
+ |----|----|
1108
+ | `label="…"` | `strings={{ label: "…" }}` |
1109
+ | `enableMiniPlayer={false}` | `dock={{ enabled: false }}` |
1110
+ | `enableHighlighting={false}` | `highlight={{ enabled: false }}` |
1111
+ | `enableClickToSeek={false}` | `highlight={{ clickToSeek: false }}` |
1112
+ | `trailLength={4}` | `highlight={{ trailLength: 4 }}` |
1113
+
1114
+ ```diff
1115
+ <AudioPlayer
1116
+ slug={slug}
1117
+ audioEntry={audioEntry}
1118
+ - label={`Listen to "${title}"`}
1119
+ - enableMiniPlayer={true}
1120
+ - enableHighlighting={true}
1121
+ - trailLength={4}
1122
+ + strings={{ label: `Listen to "${title}"` }}
1123
+ + highlight={{ trailLength: 4 }}
1124
+ />
1125
+ ```
1126
+
1127
+ ### Behaviour changes
1128
+
1129
+ - **Arrow keys skip 15 seconds, not 5.** Set `skipSeconds={5}` to keep the old jump.
1130
+ - **Speed, volume, mute and highlighting are remembered** across pages and visits. Set
1131
+ `rememberPreferences={false}` to opt out.
1132
+ - **Autoscroll is off by default.** It used to follow the spoken word with no way to
1133
+ stop it, taking over the reader's scroll position. Pass `autoScroll="paragraph"` to
1134
+ keep the old behaviour.
1135
+ - **Starting one player pauses the others.** Pass `exclusive={false}` to allow overlap.
1136
+ - **A failed load shows an error state with a retry**, rather than leaving controls
1137
+ that look interactive but do nothing.
1138
+ - **Click-to-seek no longer depends on highlighting.** Turning highlighting off used to
1139
+ disable it silently.
1140
+ - **Autoscroll yields to the reader.** Scrolling suspends it for a few seconds rather
1141
+ than dragging the page back.
1142
+
1143
+ ### Rehype plugin
1144
+
1145
+ `classPrefix` is removed. It renamed the word-span class while `.vocasync-word` stayed
1146
+ hardcoded in the stylesheet, the player and the WordPress plugin, so setting it
1147
+ silently broke highlighting. Use `extraWordClass` to add a class alongside
1148
+ `vocasync-word`, or drive the engine headlessly for entirely different markup.
1149
+
1150
+ ```diff
1151
+ - [rehypeAudioWords, { collectionName, audioMapPath, classPrefix: "vocasync" }]
1152
+ + [rehypeAudioWords, { collectionName, audioMapPath }]
1153
+ ```
1154
+
1155
+ ### Astro 7
1156
+
1157
+ Astro 7 replaced its default Markdown processor, so `@astrojs/markdown-remark` is no
1158
+ longer installed with it — and rehype plugins do not run without it. On Astro 7:
1159
+
1160
+ ```bash
1161
+ bun add @astrojs/markdown-remark
1162
+ ```
1163
+
1164
+ Astro 4, 5 and 6 need nothing extra.
1165
+
599
1166
  ## Troubleshooting
600
1167
 
601
1168
  ### "No VocaSync configuration found"
602
1169
 
603
1170
  Create a `vocasync.config.mjs` file in your project root.
604
1171
 
605
- ### Words not highlighting
1172
+ ### No words are highlighted
1173
+
1174
+ 1. **On Astro 7, install `@astrojs/markdown-remark`.** Astro 7 stopped bundling it, and
1175
+ rehype plugins — which is what produces the word spans — do not run without it. The
1176
+ build fails with a message naming the package.
1177
+ 2. Check the rehype plugins are registered in `astro.config.mjs`, and that
1178
+ `collectionName` and `audioMapPath` match your setup.
1179
+ 3. Make sure the article content is inside the element named by `articleSelector`
1180
+ (`[data-article-body]` by default).
1181
+ 4. View source: each word should be a `<span class="vocasync-word" data-i="…">`. If the
1182
+ spans are absent the rehype plugin did not run; if they are present but nothing
1183
+ lights up, the audio map and the page disagree — see below.
1184
+
1185
+ ### "cannot be force-aligned"
1186
+
1187
+ The language can be narrated but has no forced-alignment model, so it cannot carry the
1188
+ word timings highlighting needs. Set `align: false` in `vocasync.config.mjs`, or in a
1189
+ single post's frontmatter, to narrate it without highlighting. See
1190
+ [Supported Languages](#supported-languages) for which is which.
1191
+
1192
+ ### A post has audio but no highlighting
1193
+
1194
+ Check whether it was synthesised with `align: false` — deliberately unaligned posts
1195
+ carry no word timings, so the player omits the highlighting toggle rather than showing
1196
+ an inert control, and the rehype plugin does not wrap its words.
1197
+
1198
+ ### Highlighting drifts partway through a post
1199
+
1200
+ The audio map is stale. `data-i` indices are assigned at build time against the word
1201
+ stream in `audio-map.json`, so editing a post without re-running `npx vocasync sync`
1202
+ leaves the spans pointing at the wrong words from the edit onwards.
1203
+
1204
+ ### The player is invisible or unstyled
1205
+
1206
+ The stylesheet is injected by the integration. If you passed `styles: false`, import it
1207
+ yourself — `@vocasync/astro/styles/vocasync.css`. If you are driving the engine
1208
+ headlessly with your own markup, you still need `content.css` for the word spans.
1209
+
1210
+ ### My CSS override does not apply
1211
+
1212
+ It should — every rule the player ships is inside a cascade layer *and* wrapped in
1213
+ `:where()`, so it has zero specificity and loses to anything you write. If an override
1214
+ is not landing, it is almost certainly a selector that does not match rather than a
1215
+ specificity problem. Check the element in devtools; the player root is
1216
+ `.vocasync-player`, and it carries `data-variant`, `data-size` and `data-player-state`
1217
+ attributes you can target.
1218
+
1219
+ You should never need `!important`. If you do, that is a bug worth reporting.
1220
+
1221
+ ### The player stays light when my site goes dark
1222
+
1223
+ `.dark`, `[data-theme="dark"]` and `[data-mode="dark"]` are recognised automatically.
1224
+ If your site signals dark mode some other way, name it:
1225
+
1226
+ ```js
1227
+ vocasync({ theme: { darkSelector: '[data-appearance="night"]' } })
1228
+ ```
1229
+
1230
+ If your site has its own tokens, the tidier fix is to point ours at them — then the
1231
+ player follows whatever your tokens do, in both directions.
1232
+
1233
+ ### The play button does nothing
1234
+
1235
+ Check `data-player-state` on the player root:
1236
+
1237
+ - `error` — the audio failed to load. Usually an expired publishable key; re-run
1238
+ `npx vocasync sync`. The player shows a retry button.
1239
+ - `no-audio` — there is no entry for this `slug` in the audio map.
1240
+ - `ready` with `data-player-buffering` — it is still loading, not broken.
1241
+
1242
+ Browsers also block playback that is not user-initiated; a `NotAllowedError` in the
1243
+ console after a programmatic `play()` is expected, not a fault.
1244
+
1245
+ ### Several players on one page interfere
1246
+
1247
+ They should not, but each needs its own `articleSelector` if more than one article body
1248
+ is on the page — otherwise click-to-seek cannot tell which player owns a word, and the
1249
+ first one wins. A warning is logged in that case.
606
1250
 
607
- 1. Make sure the rehype plugin is configured in `astro.config.mjs`
608
- 2. Check that `collectionName` matches your collection
609
- 3. Verify `audioMapPath` points to your audio map
610
- 4. Ensure content is wrapped in `[data-article-body]`
1251
+ By default, starting one player pauses the others. Pass `exclusive={false}` if you want
1252
+ them to overlap.
611
1253
 
612
- ### Audio not playing
1254
+ ### The player stops working after a client-side navigation
613
1255
 
614
- 1. Run `npx vocasync sync` to generate audio
615
- 2. Check that `audio-map.json` exists and has entries
616
- 3. Verify the `slug` prop matches your content slug
1256
+ The player boots on `astro:page-load` and tears down on `astro:before-swap`, so
1257
+ `<ClientRouter />` is supported. If you are using a different client-side router, call
1258
+ `install()` from `@vocasync/astro/player-core` after each navigation.
617
1259
 
618
1260
  ### CLI errors
619
1261