@pie-players/pie-assessment-toolkit 0.3.75 → 1.0.0-beta.1

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 (142) hide show
  1. package/README.md +451 -541
  2. package/custom-elements.json +1315 -0
  3. package/dist/attempt/TestSession.d.ts +0 -1
  4. package/dist/attempt/TestSession.js +10 -5
  5. package/dist/components/ItemScope.custom-element.js +1 -1
  6. package/dist/components/ItemToolBar.custom-element.js +1 -1
  7. package/dist/components/PieAssessmentToolkit.custom-element.js +8 -8
  8. package/dist/components/SectionToolBar.custom-element.js +1 -1
  9. package/dist/components/chunks/{ItemToolBar-7tt7v2xp.js → ItemToolBar-3zrc4p3d.js} +4 -4
  10. package/dist/components/chunks/{ItemToolBar-jx38w99s.js → ItemToolBar-66hcwmfw.js} +2 -2
  11. package/dist/components/chunks/ItemToolBar-asenkvx6.js +40 -0
  12. package/dist/components/chunks/ItemToolBar-hzc5wyjp.js +2 -0
  13. package/dist/components/chunks/{ItemToolBar-97hx60z4.js → ItemToolBar-kkj69ptr.js} +1 -1
  14. package/dist/components/chunks/sre-engine-bj997w4b.js +1 -0
  15. package/dist/context/assessment-toolkit-context.d.ts +6 -0
  16. package/dist/index.d.ts +7 -7
  17. package/dist/index.js +4 -10
  18. package/dist/policy/core/PolicySource.d.ts +1 -1
  19. package/dist/policy/core/ToolPolicyEngine.d.ts +46 -7
  20. package/dist/policy/core/ToolPolicyEngine.js +73 -16
  21. package/dist/policy/core/compose-decision.d.ts +3 -3
  22. package/dist/policy/core/compose-decision.js +32 -30
  23. package/dist/policy/core/decision-types.d.ts +51 -34
  24. package/dist/policy/core/feature-decision.d.ts +17 -15
  25. package/dist/policy/core/feature-decision.js +11 -13
  26. package/dist/policy/core/pnp-policy-inputs.d.ts +7 -3
  27. package/dist/policy/core/pnp-policy-inputs.js +17 -33
  28. package/dist/policy/core/provenance.d.ts +2 -2
  29. package/dist/policy/core/tool-parameters.d.ts +12 -0
  30. package/dist/policy/core/tool-parameters.js +27 -0
  31. package/dist/policy/engine.d.ts +1 -1
  32. package/dist/policy/sources/PnpPolicySource.d.ts +18 -24
  33. package/dist/policy/sources/PnpPolicySource.js +57 -29
  34. package/dist/runtime/SectionControllerBinding.d.ts +6 -2
  35. package/dist/runtime/SectionControllerBinding.js +21 -15
  36. package/dist/runtime/adapter/subscriber-fanout.d.ts +0 -1
  37. package/dist/runtime/adapter/subscriber-fanout.js +1 -4
  38. package/dist/runtime/composition-emit-scheduler.d.ts +3 -3
  39. package/dist/runtime/composition-emit-scheduler.js +1 -1
  40. package/dist/runtime/content-region.d.ts +0 -4
  41. package/dist/runtime/content-region.js +2 -2
  42. package/dist/runtime/core/SectionEngineCore.d.ts +0 -2
  43. package/dist/runtime/core/SectionEngineCore.js +0 -4
  44. package/dist/runtime/core/cohort.d.ts +0 -5
  45. package/dist/runtime/core/cohort.js +0 -9
  46. package/dist/runtime/core/engine-output.d.ts +3 -2
  47. package/dist/runtime/core/engine-transition.js +3 -2
  48. package/dist/runtime/registration-events.d.ts +11 -14
  49. package/dist/runtime/runtime-id.d.ts +1 -1
  50. package/dist/runtime/runtime-id.js +1 -1
  51. package/dist/runtime/shell-scope.d.ts +4 -4
  52. package/dist/runtime/shell-scope.js +15 -9
  53. package/dist/runtime/tool-host-contract.d.ts +0 -4
  54. package/dist/runtime/tool-host-contract.js +1 -1
  55. package/dist/services/AccessibilityCatalogResolver.d.ts +21 -31
  56. package/dist/services/AccessibilityCatalogResolver.js +29 -42
  57. package/dist/services/ElementToolStateStore.d.ts +32 -61
  58. package/dist/services/ElementToolStateStore.js +37 -67
  59. package/dist/services/HighlightCoordinator.d.ts +9 -21
  60. package/dist/services/HighlightCoordinator.js +52 -80
  61. package/dist/services/RangeSerializer.d.ts +4 -35
  62. package/dist/services/RangeSerializer.js +4 -48
  63. package/dist/services/SSMLExtractor.d.ts +8 -31
  64. package/dist/services/SSMLExtractor.js +18 -40
  65. package/dist/services/TTSService.d.ts +51 -57
  66. package/dist/services/TTSService.js +323 -284
  67. package/dist/services/ToolCoordinator.d.ts +6 -49
  68. package/dist/services/ToolCoordinator.js +25 -61
  69. package/dist/services/ToolRegistry.d.ts +83 -80
  70. package/dist/services/ToolRegistry.js +91 -67
  71. package/dist/services/ToolkitCoordinator.d.ts +83 -81
  72. package/dist/services/ToolkitCoordinator.js +186 -174
  73. package/dist/services/framework-error.d.ts +30 -7
  74. package/dist/services/framework-error.js +10 -13
  75. package/dist/services/interfaces.d.ts +51 -71
  76. package/dist/services/section-controller-types.d.ts +7 -7
  77. package/dist/services/section-session-assignment.js +6 -8
  78. package/dist/services/spoken-audio-cards.d.ts +2 -4
  79. package/dist/services/spoken-audio-cards.js +2 -4
  80. package/dist/services/tool-config-validation.d.ts +5 -7
  81. package/dist/services/tool-config-validation.js +11 -26
  82. package/dist/services/tool-context.d.ts +39 -24
  83. package/dist/services/tool-context.js +158 -92
  84. package/dist/services/tool-failure.d.ts +30 -0
  85. package/dist/services/tool-failure.js +11 -0
  86. package/dist/services/tool-icons.d.ts +1 -2
  87. package/dist/services/tool-icons.js +2 -2
  88. package/dist/services/tool-instance-id.d.ts +8 -6
  89. package/dist/services/tool-instance-id.js +12 -18
  90. package/dist/services/tool-providers/TTSToolProvider.d.ts +6 -43
  91. package/dist/services/tool-providers/TTSToolProvider.js +7 -63
  92. package/dist/services/tool-providers/ToolProviderApi.d.ts +0 -7
  93. package/dist/services/tool-providers/ToolProviderRegistry.d.ts +7 -42
  94. package/dist/services/tool-providers/ToolProviderRegistry.js +21 -63
  95. package/dist/services/tool-request.d.ts +4 -0
  96. package/dist/services/tool-request.js +7 -2
  97. package/dist/services/toolbar-decided-tools.d.ts +2 -0
  98. package/dist/services/toolbar-decided-tools.js +2 -0
  99. package/dist/services/toolbar-items.js +2 -5
  100. package/dist/services/tools-config-normalizer.d.ts +18 -9
  101. package/dist/services/tools-config-normalizer.js +25 -19
  102. package/dist/services/tts/browser-provider.d.ts +2 -5
  103. package/dist/services/tts/browser-provider.js +13 -22
  104. package/dist/services/tts/catalog-span-alignment.js +14 -7
  105. package/dist/services/tts/flat-tree.d.ts +0 -7
  106. package/dist/services/tts/flat-tree.js +2 -2
  107. package/dist/services/tts/generated-speech/dom/to-chunk-inputs.d.ts +2 -2
  108. package/dist/services/tts/generated-speech/index.d.ts +1 -1
  109. package/dist/services/tts/generated-speech/index.js +1 -1
  110. package/dist/services/tts/generated-speech/types.d.ts +1 -1
  111. package/dist/services/tts/generated-speech/types.js +1 -1
  112. package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +10 -12
  113. package/dist/services/tts/highlight-target-resolver.d.ts +12 -0
  114. package/dist/services/tts/math-aware-text-processing.js +10 -29
  115. package/dist/services/tts/math-speech.d.ts +1 -1
  116. package/dist/services/tts/math-speech.js +3 -0
  117. package/dist/services/tts/mathml-sanitization.d.ts +7 -0
  118. package/dist/services/tts/mathml-sanitization.js +9 -1
  119. package/dist/services/tts/provider-options.d.ts +12 -1
  120. package/dist/services/tts/ssml/spoken-text.js +1 -1
  121. package/dist/services/tts/start-failure.d.ts +0 -7
  122. package/dist/services/tts/start-failure.js +1 -1
  123. package/dist/services/tts/text-segmentation.d.ts +5 -0
  124. package/dist/services/tts/text-segmentation.js +13 -10
  125. package/dist/services/tts-runtime-config.d.ts +32 -12
  126. package/dist/services/tts-runtime-config.js +14 -20
  127. package/dist/tools/content-capability-resolution.d.ts +2 -2
  128. package/dist/tools/registration.d.ts +7 -6
  129. package/dist/tools/registration.js +10 -9
  130. package/dist/tools/registrations/toolbar-registration-helpers.d.ts +6 -0
  131. package/dist/tools/registrations/toolbar-registration-helpers.js +6 -0
  132. package/dist/tools/tool-surface-host.js +1 -8
  133. package/package.json +8 -6
  134. package/dist/components/chunks/ItemToolBar-bxwyhr5p.js +0 -2
  135. package/dist/components/chunks/ItemToolBar-rd2bb4p6.js +0 -40
  136. package/dist/components/chunks/sre-engine-jd8cc08x.js +0 -1
  137. package/dist/services/ContextVariableStore.d.ts +0 -113
  138. package/dist/services/ContextVariableStore.js +0 -206
  139. package/dist/services/tts-control-events.d.ts +0 -13
  140. package/dist/services/tts-control-events.js +0 -7
  141. package/dist/utils/logger.d.ts +0 -6
  142. package/dist/utils/logger.js +0 -10
@@ -1,26 +1,28 @@
1
1
  /**
2
2
  * TTSService
3
3
  *
4
- * Text-to-speech service with pluggable provider architecture.
5
- * Manages playback state, coordinates multiple TTS entry points,
6
- * and integrates with HighlightCoordinator for word highlighting.
4
+ * Owns one read-aloud session: the installed provider, playback state, and the
5
+ * word and sentence highlights painted through HighlightCoordinator.
7
6
  *
8
- * Features:
9
- * - Pluggable TTS providers (browser, AWS Polly, etc.)
10
- * - QTI 3.0 accessibility catalogs (pre-authored spoken content)
11
- * - Unified playback state management
12
- * - Prevents conflicts from simultaneous speech
13
- * - Word highlighting integration
14
- * - Playback controls: play, pause, resume, stop
15
- *
16
- * Part of PIE Assessment Toolkit.
7
+ * Layout:
8
+ * - Provider and host wiring: initialize, setCatalogResolver, the highlight
9
+ * target resolver and math-speech sources.
10
+ * - Content resolution: catalog spoken card, then catalog-composed chunks
11
+ * (script and/or recording with a plain fallback), then generated speech.
12
+ * - Speech plan: structural pauses, seek segments, sentence segments and the
13
+ * normalized-to-DOM position map.
14
+ * - Playback: speakContent → executeSpeakPlayback, the run guard (speakRunId,
15
+ * runOwner), the pause hold and the playback-start barrier.
16
+ * - Highlight painting: boundary handling, the host resolver remap, catalog
17
+ * highlight plans.
18
+ * - Controls and state: pause/resume/stop/seek/rate, setState and listeners.
17
19
  */
18
- import type { ITTSProvider, TTSConfig, TTSProviderCapabilities } from "@pie-players/pie-tts";
20
+ import type { ITTSProvider, TTSConfig } from "@pie-players/pie-tts";
19
21
  import type { AccessibilityCatalogResolver } from "./AccessibilityCatalogResolver.js";
20
22
  import type { HighlightCoordinatorApi, SpeakOptions } from "./interfaces.js";
21
23
  import type { TTSHighlightTargetResolverProvider } from "./tts/highlight-target-resolver.js";
22
24
  import { type SREMathSpeechOptions } from "./tts/math-speech.js";
23
- export type { ITTSProvider, ITTSProviderImplementation, TTSConfig, TTSProviderCapabilities, } from "@pie-players/pie-tts";
25
+ import type { ToolkitTTSConfig } from "./tts/provider-options.js";
24
26
  /**
25
27
  * Playback state
26
28
  */
@@ -32,8 +34,6 @@ export declare enum PlaybackState {
32
34
  ERROR = "error"
33
35
  }
34
36
  /**
35
- * TTSService
36
- *
37
37
  * Instantiable service for text-to-speech functionality.
38
38
  * Each instance manages its own playback state.
39
39
  */
@@ -57,6 +57,7 @@ export declare class TTSService {
57
57
  private listeners;
58
58
  private lastError;
59
59
  private speakRunId;
60
+ private runOwner;
60
61
  private currentBoundaryOffset;
61
62
  private activeWordBoundaryOffset;
62
63
  private seekSegments;
@@ -74,12 +75,24 @@ export declare class TTSService {
74
75
  private pendingPlaybackRateRequest;
75
76
  private activePlaybackRate;
76
77
  private activeHighlightMode;
78
+ private wordlessPartHighlight;
77
79
  private lastRenderedRegionTarget;
78
80
  private telemetryReporter;
79
81
  private readonly generatedMathSpeechResolver;
80
- constructor();
81
82
  private clearPlaybackStartBarrier;
82
83
  private notifyPlaybackStarted;
84
+ /**
85
+ * A word-mode part whose playback sends no boundaries, such as a server
86
+ * response without speech marks, highlights as a sentence-mode read does.
87
+ * Catalog chunks and a single speak highlight the same in both modes.
88
+ */
89
+ private highlightWordlessPlayback;
90
+ /**
91
+ * Defers marking the run playing, and the highlights queued through
92
+ * runWhenPlaybackStarts, until the provider or the recording signals that
93
+ * audio started. Returns the barrier's cleanup, or null when nothing will
94
+ * signal a start, in which case the caller marks the run playing itself.
95
+ */
83
96
  private installPlaybackStartBarrier;
84
97
  private runWhenPlaybackStarts;
85
98
  /** Resolves when run `runId` may start its next part: at once unless paused. */
@@ -105,13 +118,11 @@ export declare class TTSService {
105
118
  private emitTelemetry;
106
119
  /**
107
120
  * Initialize TTS service with a provider
108
- *
109
- * @param provider TTS provider instance
110
- * @param config Provider configuration
111
121
  */
112
- initialize(provider: ITTSProvider, config?: Partial<TTSConfig>): Promise<void>;
122
+ initialize(provider: ITTSProvider, config?: Partial<ToolkitTTSConfig>): Promise<void>;
113
123
  /**
114
- * Update rate, pitch, voice or provider options without reinitializing.
124
+ * Update rate, pitch, volume, voice or provider options without
125
+ * reinitializing.
115
126
  * `providerOptions` merge over the ones already configured.
116
127
  */
117
128
  updateSettings(settings: Partial<TTSConfig>): Promise<void>;
@@ -153,8 +164,6 @@ export declare class TTSService {
153
164
  *
154
165
  * When set, the speak() method will check for pre-authored spoken
155
166
  * content in catalogs before falling back to generated TTS.
156
- *
157
- * @param resolver AccessibilityCatalogResolver instance
158
167
  */
159
168
  setCatalogResolver(resolver: AccessibilityCatalogResolver): void;
160
169
  private getHighlightResolverRuntime;
@@ -171,10 +180,6 @@ export declare class TTSService {
171
180
  */
172
181
  private paintTTSWord;
173
182
  private paintTTSSentenceRanges;
174
- /**
175
- * Get provider capabilities
176
- */
177
- getCapabilities(): TTSProviderCapabilities | null;
178
183
  private providerOptions;
179
184
  /** The longest text the provider accepts in one speak, when it declares one. */
180
185
  private maxTextLength;
@@ -187,8 +192,8 @@ export declare class TTSService {
187
192
  /** Segments no longer than the provider's `maxTextLength`, offsets kept. */
188
193
  private segmentsWithinLimit;
189
194
  /**
190
- * Build a character-by-character map from normalized text positions to DOM positions
191
- * This handles the complexity of whitespace normalization
195
+ * Text-collection options for `locale`, with the provider's boundary-spacing
196
+ * mode when it names a known one.
192
197
  */
193
198
  private getTextProcessingOptions;
194
199
  /**
@@ -203,12 +208,15 @@ export declare class TTSService {
203
208
  * this service was initialized with.
204
209
  */
205
210
  getMathSpeechOptions(): SREMathSpeechOptions | undefined;
211
+ /**
212
+ * Rebuilds normalizedToDOM from `element`'s visible text; traced runs also
213
+ * log how it differs from `spokenText`.
214
+ */
206
215
  private buildPositionMap;
207
216
  private getStructuralPauseProfile;
208
217
  private resolvePauseMsFromUnits;
209
218
  private resolveHighlightMode;
210
219
  private hasExplicitBreakSemantics;
211
- private isElementHidden;
212
220
  private getBoundaryStrength;
213
221
  private getBoundaryAnchor;
214
222
  /**
@@ -246,12 +254,19 @@ export declare class TTSService {
246
254
  * running continues.
247
255
  */
248
256
  speak(target: Range | Element, options?: SpeakOptions): Promise<void>;
257
+ /**
258
+ * Sets the rate, pitch and volume a run starts at, after any rate write in
259
+ * flight. The run has no playback yet, so nothing restarts.
260
+ */
261
+ private applyRunSettings;
249
262
  /**
250
263
  * Suppression is read from the live ancestors of what is read, because the
251
264
  * element carrying it may sit above the content root.
252
265
  */
253
266
  private isSuppressedTarget;
254
267
  private resolveElementTarget;
268
+ /** Whether the root's card, or a card of a node inside it, would be read. */
269
+ private holdsSpokenCard;
255
270
  private resolveRangeTarget;
256
271
  private speakContent;
257
272
  /**
@@ -327,7 +342,8 @@ export declare class TTSService {
327
342
  seekForward(units?: number): Promise<void>;
328
343
  seekBackward(units?: number): Promise<void>;
329
344
  /**
330
- * Stop playback
345
+ * Stop playback and release the run owner. A run that ends on its own keeps
346
+ * its owner, so the owning control can replay it.
331
347
  */
332
348
  stop(): void;
333
349
  /**
@@ -340,41 +356,19 @@ export declare class TTSService {
340
356
  * A disposed service cannot speak or be initialized again.
341
357
  */
342
358
  dispose(): void;
343
- /**
344
- * Request UI-level TTS controls to hand off/deactivate.
345
- *
346
- * This is intentionally separate from playback controls so hosts can orchestrate
347
- * control handoff explicitly (for example: stop playback, then dismiss controls).
348
- */
349
- requestControlHandoff(): void;
350
- /**
351
- * Check if currently playing
352
- */
353
- isPlaying(): boolean;
354
- /**
355
- * Check if paused
356
- */
357
- isPaused(): boolean;
358
359
  /**
359
360
  * Get current state
360
361
  */
361
362
  getState(): PlaybackState;
362
- /**
363
- * Get current text being spoken
364
- */
365
- getCurrentText(): string | null;
366
- /**
367
- * Get the last error message
368
- * Returns null if no error has occurred
369
- */
370
- getLastError(): string | null;
363
+ getRunOwner(): string | null;
371
364
  /**
372
365
  * Subscribe to playback state changes. The returned function unsubscribes;
373
366
  * each subscription is its own, so the same callback can be subscribed twice.
374
367
  */
375
368
  onStateChange(callback: (state: PlaybackState) => void): () => void;
376
369
  /**
377
- * Set state and notify listeners
370
+ * Set state and notify listeners. `announceUnchanged` notifies listeners even
371
+ * when the state does not change; telemetry fires only on a change.
378
372
  */
379
373
  private setState;
380
374
  }