@pie-players/pie-tool-tts-inline 0.3.52 → 0.3.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -100,6 +100,7 @@ toolCoordinator.showTool('tts-passage-1');
100
100
  - `ttsService` - ITTSService instance (required)
101
101
  - `coordinator` - IToolCoordinator instance (optional, for visibility management)
102
102
  - `speedOptions` - Optional speed options controlling inline speed button rendering
103
+ - `showSingleSpeedOption` - Optional boolean to show a one-option speed group (hidden by default)
103
104
 
104
105
  ### `speedOptions` Configuration
105
106
 
@@ -109,7 +110,7 @@ provider settings.
109
110
 
110
111
  ```javascript
111
112
  const ttsButton = document.createElement("pie-tool-tts-inline");
112
- ttsButton.speedOptions = [2, 1.25, 1.5]; // rendered in this order
113
+ ttsButton.speedOptions = [2, 1.25, 1.5]; // host options keep this order; Normal is added if omitted
113
114
  ```
114
115
 
115
116
  For hosts that need semantic button copy, pass object-form options. `rate`
@@ -119,22 +120,28 @@ accessible text.
119
120
  ```javascript
120
121
  ttsButton.speedOptions = [
121
122
  { rate: 0.8, label: "Slow", ariaLabel: "Slow speed" },
123
+ { rate: 1, label: "Normal", ariaLabel: "Normal speed", default: true },
122
124
  { rate: 1.5, label: "Fast", ariaLabel: "Fast speed" }
123
125
  ];
124
126
  ```
125
127
 
126
128
  Semantics:
127
129
 
128
- - Omitted or non-array: defaults to `[0.8, 1.25]`.
129
- - Explicit `[]`: no speed buttons rendered.
130
- - Invalid-only values: fall back to `[0.8, 1.25]`.
130
+ - Omitted or non-array: defaults to visible `Slow`, `Normal`, and `Fast` choices, with `Normal` selected.
131
+ - Explicit `[]`: no speed choices rendered; playback speed is reset to `1.0`.
132
+ - Invalid-only values: fall back to the visible `Slow`, `Normal`, and `Fast` choices.
131
133
  - Numeric values and object `rate` values are deduplicated while preserving
132
134
  first-seen order.
133
135
  - Numeric options render as `{rate}x` with accessible names like
134
136
  `Speed {rate}x`.
135
137
  - Object options can customize labels; missing labels fall back to `{rate}x`,
136
138
  and missing `ariaLabel` values fall back to matching names like `Fast speed`.
137
- - `1` is excluded from rendered options.
139
+ - `1` renders as the visible `Normal` choice. If a non-empty config omits `1`,
140
+ the component adds `Normal` at the natural point in the speed scale while
141
+ preserving host-provided option order.
142
+ - One speed is always selected. Clicking the selected speed is a no-op.
143
+ - One-option speed groups are hidden by default; set `showSingleSpeedOption` to
144
+ `true` to surface a single current speed.
138
145
 
139
146
  ## Behavior
140
147
 
@@ -153,9 +160,12 @@ Semantics:
153
160
  - Fast-forward/Rewind invoke sentence-jump seek on `ITTSService`
154
161
  - Speed buttons call `ttsService.setPlaybackRate(rate)` when available,
155
162
  otherwise `ttsService.updateSettings({ rate })`
156
- - Selecting another speed switches active state to that option
157
- - Clicking the currently active speed resets back to `1x`
158
- - If `speedOptions` is `[]`, speed controls are omitted while rewind/forward/stop still render
163
+ - Speed choices render as a named `Playback speed` radio group with
164
+ `aria-checked` state
165
+ - Selecting another speed switches the active radio to that option
166
+ - Clicking the currently active speed leaves the selection unchanged
167
+ - If `speedOptions` is `[]`, speed controls are omitted and playback rate is
168
+ reset to `1x` while rewind/forward/stop still render
159
169
  6. **Keyboard Interaction**: Arrow keys move between controls; Tab enters/leaves the toolbar
160
170
  7. **Cleanup**: Unregisters from coordinator on unmount
161
171
 
@@ -165,6 +175,7 @@ When used with the section player, this tool benefits from extracted catalogs
165
175
  when a host/import pipeline runs `SSMLExtractor` before render:
166
176
 
167
177
  **Author embeds SSML in content:**
178
+
168
179
  ```html
169
180
  <div>
170
181
  <speak>Solve <prosody rate="slow">x squared plus two</prosody>.</speak>
@@ -173,11 +184,13 @@ when a host/import pipeline runs `SSMLExtractor` before render:
173
184
  ```
174
185
 
175
186
  **Preprocessing extracts SSML:**
187
+
176
188
  - Generates catalog with ID like `auto-prompt-q1-0`
177
189
  - Adds `data-catalog-idref="auto-prompt-q1-0"` to visual content
178
190
  - Provides `config.extractedCatalogs` for runtime catalog registration
179
191
 
180
192
  **Tool uses extracted catalog:**
193
+
181
194
  - User clicks TTS button in header
182
195
  - Tool calls `ttsService.speak(text, { catalogId: 'auto-prompt-q1-0' })`
183
196
  - TTSService finds SSML in extracted catalogs
@@ -194,6 +207,28 @@ The component uses scoped styles and doesn't require external CSS. Styling uses
194
207
  - **Speed state**: Active speed button receives distinct token-driven styling
195
208
  - **Disabled**: Reduced opacity, no pointer
196
209
 
210
+ Hosts that need to theme the trigger's active/open state should prefer these
211
+ component-scoped variables instead of overriding broad semantic tokens such as
212
+ `--pie-primary`:
213
+
214
+ ```css
215
+ --pie-tool-trigger-active-background: Active/open trigger background
216
+ --pie-tool-trigger-active-color: Active/open trigger foreground
217
+ --pie-tool-trigger-active-border-color: Active/open trigger border
218
+ ```
219
+
220
+ If unset, the trigger keeps the existing defaults: active background and border
221
+ derive from `--pie-primary`, while foreground continues through
222
+ `--pie-button-color` / `--pie-text`. Hosts remain responsible for maintaining
223
+ WCAG AA foreground/background contrast when overriding active trigger colors.
224
+
225
+ Ordinary trigger and control button styling also preserves these legacy aliases:
226
+ `--pie-button-background-color`, `--pie-button-border-color`, and
227
+ `--pie-button-hover-background-color`. They remain supported for host
228
+ compatibility, but fall back through the canonical `--pie-button-bg`,
229
+ `--pie-button-border`, and `--pie-button-hover-bg` tokens before broad surface
230
+ tokens.
231
+
197
232
  ## Architecture
198
233
 
199
234
  This tool follows the PIE Assessment Toolkit tool pattern: