@pie-players/pie-assessment-toolkit 0.3.74 → 1.0.0-beta.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 (257) hide show
  1. package/README.md +658 -714
  2. package/custom-elements.json +1315 -0
  3. package/dist/attempt/TestSession.d.ts +1 -21
  4. package/dist/attempt/TestSession.js +16 -102
  5. package/dist/components/ItemScope.custom-element.d.ts +1 -0
  6. package/dist/components/ItemScope.custom-element.js +1 -0
  7. package/dist/components/ItemToolBar.custom-element.js +1 -1
  8. package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
  9. package/dist/components/SectionToolBar.custom-element.js +1 -1
  10. package/dist/components/chunks/ItemToolBar-3zrc4p3d.js +4 -0
  11. package/dist/components/chunks/ItemToolBar-66hcwmfw.js +2 -0
  12. package/dist/components/chunks/ItemToolBar-9gqhfxtn.js +40 -0
  13. package/dist/components/chunks/ItemToolBar-hzc5wyjp.js +2 -0
  14. package/dist/components/chunks/{ItemToolBar-gmrryv2v.js → ItemToolBar-kkj69ptr.js} +1 -1
  15. package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
  16. package/dist/components/chunks/sre-engine-bj997w4b.js +1 -0
  17. package/dist/components/item-scope-element.d.ts +2 -0
  18. package/dist/components/item-scope-element.js +2 -0
  19. package/dist/context/assessment-toolkit-context.d.ts +33 -6
  20. package/dist/index.d.ts +25 -50
  21. package/dist/index.js +15 -45
  22. package/dist/policy/core/PolicySource.d.ts +2 -2
  23. package/dist/policy/core/ToolPolicyEngine.d.ts +118 -34
  24. package/dist/policy/core/ToolPolicyEngine.js +203 -56
  25. package/dist/policy/core/compose-decision.d.ts +28 -7
  26. package/dist/policy/core/compose-decision.js +95 -74
  27. package/dist/policy/core/decision-types.d.ts +98 -55
  28. package/dist/policy/core/feature-decision.d.ts +28 -19
  29. package/dist/policy/core/feature-decision.js +15 -11
  30. package/dist/policy/core/pnp-policy-inputs.d.ts +29 -35
  31. package/dist/policy/core/pnp-policy-inputs.js +40 -88
  32. package/dist/policy/core/provenance.d.ts +10 -5
  33. package/dist/policy/core/provenance.js +1 -1
  34. package/dist/policy/core/tool-parameters.d.ts +11 -0
  35. package/dist/policy/core/tool-parameters.js +15 -0
  36. package/dist/policy/engine.d.ts +7 -23
  37. package/dist/policy/engine.js +5 -20
  38. package/dist/policy/sources/PnpPolicySource.d.ts +43 -68
  39. package/dist/policy/sources/PnpPolicySource.js +133 -132
  40. package/dist/runtime/SectionControllerBinding.d.ts +283 -0
  41. package/dist/runtime/SectionControllerBinding.js +456 -0
  42. package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
  43. package/dist/runtime/SectionRuntimeEngine.js +30 -372
  44. package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
  45. package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
  46. package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
  47. package/dist/runtime/adapter/dom-event-bridge.js +17 -44
  48. package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -3
  49. package/dist/runtime/adapter/subscriber-fanout.js +2 -6
  50. package/dist/runtime/catalog-context.d.ts +19 -0
  51. package/dist/runtime/catalog-context.js +28 -0
  52. package/dist/runtime/composition-emit-scheduler.d.ts +12 -18
  53. package/dist/runtime/composition-emit-scheduler.js +10 -16
  54. package/dist/runtime/content-language.d.ts +32 -0
  55. package/dist/runtime/content-language.js +46 -0
  56. package/dist/runtime/content-region.d.ts +13 -0
  57. package/dist/runtime/content-region.js +29 -0
  58. package/dist/runtime/content-registration.d.ts +13 -0
  59. package/dist/runtime/content-registration.js +25 -0
  60. package/dist/runtime/core/SectionEngineCore.d.ts +2 -4
  61. package/dist/runtime/core/SectionEngineCore.js +2 -6
  62. package/dist/runtime/core/cohort.d.ts +1 -6
  63. package/dist/runtime/core/cohort.js +1 -10
  64. package/dist/runtime/core/engine-input.d.ts +18 -30
  65. package/dist/runtime/core/engine-input.js +11 -12
  66. package/dist/runtime/core/engine-output.d.ts +17 -40
  67. package/dist/runtime/core/engine-output.js +9 -21
  68. package/dist/runtime/core/engine-readiness.d.ts +5 -37
  69. package/dist/runtime/core/engine-readiness.js +8 -41
  70. package/dist/runtime/core/engine-resolver.d.ts +46 -74
  71. package/dist/runtime/core/engine-resolver.js +18 -43
  72. package/dist/runtime/core/engine-state.d.ts +28 -36
  73. package/dist/runtime/core/engine-state.js +18 -21
  74. package/dist/runtime/core/engine-transition.d.ts +14 -19
  75. package/dist/runtime/core/engine-transition.js +74 -53
  76. package/dist/runtime/engine.d.ts +16 -19
  77. package/dist/runtime/engine.js +12 -19
  78. package/dist/runtime/page-warnings.d.ts +13 -0
  79. package/dist/runtime/page-warnings.js +22 -0
  80. package/dist/runtime/policy-input-forwarding.d.ts +25 -0
  81. package/dist/runtime/policy-input-forwarding.js +25 -0
  82. package/dist/runtime/registration-events.d.ts +22 -14
  83. package/dist/runtime/runtime-event-claim.d.ts +8 -0
  84. package/dist/runtime/runtime-event-claim.js +15 -0
  85. package/dist/runtime/runtime-id.d.ts +1 -1
  86. package/dist/runtime/runtime-id.js +1 -1
  87. package/dist/runtime/shell-event-bridge.d.ts +45 -0
  88. package/dist/runtime/shell-event-bridge.js +127 -0
  89. package/dist/runtime/shell-registration.d.ts +73 -0
  90. package/dist/runtime/shell-registration.js +95 -0
  91. package/dist/runtime/shell-scope.d.ts +68 -0
  92. package/dist/runtime/shell-scope.js +194 -0
  93. package/dist/runtime/tool-host-contract.d.ts +8 -14
  94. package/dist/runtime/tool-host-contract.js +12 -12
  95. package/dist/runtime/unclaimed-registration-watch.d.ts +7 -0
  96. package/dist/runtime/unclaimed-registration-watch.js +23 -0
  97. package/dist/services/AccessibilityCatalogResolver.d.ts +21 -31
  98. package/dist/services/AccessibilityCatalogResolver.js +29 -42
  99. package/dist/services/ElementToolStateStore.d.ts +42 -67
  100. package/dist/services/ElementToolStateStore.js +65 -71
  101. package/dist/services/HighlightCoordinator.d.ts +28 -40
  102. package/dist/services/HighlightCoordinator.js +459 -381
  103. package/dist/services/RangeSerializer.d.ts +11 -33
  104. package/dist/services/RangeSerializer.js +88 -59
  105. package/dist/services/SSMLExtractor.d.ts +8 -31
  106. package/dist/services/SSMLExtractor.js +18 -40
  107. package/dist/services/TTSService.d.ts +159 -119
  108. package/dist/services/TTSService.js +937 -822
  109. package/dist/services/ToolCoordinator.d.ts +42 -102
  110. package/dist/services/ToolCoordinator.js +178 -256
  111. package/dist/services/ToolRegistry.d.ts +152 -133
  112. package/dist/services/ToolRegistry.js +192 -178
  113. package/dist/services/ToolkitCoordinator.d.ts +233 -237
  114. package/dist/services/ToolkitCoordinator.js +615 -557
  115. package/dist/services/audio-handoff.d.ts +6 -7
  116. package/dist/services/audio-handoff.js +20 -14
  117. package/dist/services/catalog-owner.d.ts +0 -1
  118. package/dist/services/framework-error-bus.d.ts +3 -6
  119. package/dist/services/framework-error-bus.js +3 -6
  120. package/dist/services/framework-error.d.ts +51 -13
  121. package/dist/services/framework-error.js +19 -20
  122. package/dist/services/interfaces.d.ts +189 -184
  123. package/dist/services/section-controller-types.d.ts +7 -7
  124. package/dist/services/section-session-assignment.d.ts +21 -0
  125. package/dist/services/section-session-assignment.js +80 -0
  126. package/dist/services/spoken-audio-cards.d.ts +2 -6
  127. package/dist/services/spoken-audio-cards.js +2 -6
  128. package/dist/services/tool-config-defaults.d.ts +3 -3
  129. package/dist/services/tool-config-defaults.js +3 -3
  130. package/dist/services/tool-config-validation.d.ts +9 -12
  131. package/dist/services/tool-config-validation.js +47 -87
  132. package/dist/services/tool-context.d.ts +7 -31
  133. package/dist/services/tool-context.js +99 -65
  134. package/dist/services/tool-failure.d.ts +30 -0
  135. package/dist/services/tool-failure.js +11 -0
  136. package/dist/services/tool-icons.d.ts +5 -5
  137. package/dist/services/tool-icons.js +6 -5
  138. package/dist/services/tool-instance-id.d.ts +8 -7
  139. package/dist/services/tool-instance-id.js +12 -24
  140. package/dist/services/tool-providers/TTSToolProvider.d.ts +20 -58
  141. package/dist/services/tool-providers/TTSToolProvider.js +32 -85
  142. package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -11
  143. package/dist/services/tool-providers/ToolProviderRegistry.d.ts +29 -60
  144. package/dist/services/tool-providers/ToolProviderRegistry.js +128 -144
  145. package/dist/services/tool-request.d.ts +31 -12
  146. package/dist/services/tool-request.js +31 -16
  147. package/dist/services/toolbar-decided-tools.d.ts +16 -0
  148. package/dist/services/toolbar-decided-tools.js +29 -0
  149. package/dist/services/toolbar-items.js +2 -5
  150. package/dist/services/tools-config-normalizer.d.ts +33 -29
  151. package/dist/services/tools-config-normalizer.js +26 -28
  152. package/dist/services/tts/browser-provider.d.ts +39 -6
  153. package/dist/services/tts/browser-provider.js +280 -160
  154. package/dist/services/tts/catalog-span-alignment.js +14 -7
  155. package/dist/services/tts/flat-tree.d.ts +64 -0
  156. package/dist/services/tts/flat-tree.js +269 -0
  157. package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
  158. package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
  159. package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
  160. package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
  161. package/dist/services/tts/generated-speech/dom/to-chunk-inputs.d.ts +2 -2
  162. package/dist/services/tts/generated-speech/index.d.ts +1 -1
  163. package/dist/services/tts/generated-speech/index.js +1 -1
  164. package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
  165. package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
  166. package/dist/services/tts/generated-speech/types.d.ts +1 -1
  167. package/dist/services/tts/generated-speech/types.js +1 -1
  168. package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +22 -16
  169. package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
  170. package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
  171. package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
  172. package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
  173. package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
  174. package/dist/services/tts/highlight-target-resolver.d.ts +12 -0
  175. package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
  176. package/dist/services/tts/math-aware-text-processing.js +42 -47
  177. package/dist/services/tts/math-control-names.d.ts +21 -0
  178. package/dist/services/tts/math-control-names.js +142 -0
  179. package/dist/services/tts/math-speech.d.ts +12 -1
  180. package/dist/services/tts/math-speech.js +54 -18
  181. package/dist/services/tts/mathml-sanitization.d.ts +7 -0
  182. package/dist/services/tts/mathml-sanitization.js +9 -1
  183. package/dist/services/tts/provider-options.d.ts +52 -0
  184. package/dist/services/tts/provider-options.js +1 -0
  185. package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
  186. package/dist/services/tts/ssml/spoken-text.js +29 -0
  187. package/dist/services/tts/start-failure.d.ts +4 -0
  188. package/dist/services/tts/start-failure.js +19 -0
  189. package/dist/services/tts/text-processing.d.ts +9 -0
  190. package/dist/services/tts/text-processing.js +46 -33
  191. package/dist/services/tts/text-segmentation.d.ts +12 -0
  192. package/dist/services/tts/text-segmentation.js +60 -10
  193. package/dist/services/tts-runtime-config.d.ts +54 -26
  194. package/dist/services/tts-runtime-config.js +27 -112
  195. package/dist/tools/content-capability-resolution.d.ts +9 -11
  196. package/dist/tools/content-capability-resolution.js +8 -45
  197. package/dist/tools/registration.d.ts +59 -0
  198. package/dist/tools/registration.js +55 -0
  199. package/dist/tools/registrations/toolbar-registration-helpers.d.ts +6 -0
  200. package/dist/tools/registrations/toolbar-registration-helpers.js +8 -2
  201. package/dist/tools/tool-surface-host.d.ts +6 -10
  202. package/dist/tools/tool-surface-host.js +45 -50
  203. package/dist/tools/tool-tag-map.d.ts +5 -15
  204. package/dist/tools/tool-tag-map.js +6 -20
  205. package/dist/utils/structural-equality.d.ts +11 -0
  206. package/dist/utils/structural-equality.js +47 -0
  207. package/package.json +15 -29
  208. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
  209. package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
  210. package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +0 -40
  211. package/dist/components/chunks/ItemToolBar-h4xap0t0.js +0 -4
  212. package/dist/components/chunks/ItemToolBar-wr2myaah.js +0 -2
  213. package/dist/components/chunks/sre-engine-wf9s43gg.js +0 -1
  214. package/dist/context/runtime-context-consumer.d.ts +0 -13
  215. package/dist/context/runtime-context-consumer.js +0 -18
  216. package/dist/item-loader.d.ts +0 -44
  217. package/dist/item-loader.js +0 -61
  218. package/dist/policy/core/engine-context.d.ts +0 -29
  219. package/dist/policy/core/engine-context.js +0 -27
  220. package/dist/policy/core/policy-source-tag.d.ts +0 -31
  221. package/dist/policy/core/policy-source-tag.js +0 -28
  222. package/dist/policy/internal.d.ts +0 -25
  223. package/dist/policy/internal.js +0 -25
  224. package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
  225. package/dist/runtime/adapter/coordinator-bridge.js +0 -126
  226. package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
  227. package/dist/runtime/adapter/framework-error-bridge.js +0 -46
  228. package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
  229. package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
  230. package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
  231. package/dist/runtime/core/engine-stage-derivation.js +0 -29
  232. package/dist/runtime/engine-context.d.ts +0 -39
  233. package/dist/runtime/engine-context.js +0 -31
  234. package/dist/runtime/internal.d.ts +0 -43
  235. package/dist/runtime/internal.js +0 -45
  236. package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -74
  237. package/dist/runtime/section-runtime-engine-host-context.js +0 -57
  238. package/dist/runtime/stage-emit-gate.d.ts +0 -92
  239. package/dist/runtime/stage-emit-gate.js +0 -82
  240. package/dist/services/ContextVariableStore.d.ts +0 -113
  241. package/dist/services/ContextVariableStore.js +0 -206
  242. package/dist/services/I18nService.d.ts +0 -47
  243. package/dist/services/I18nService.js +0 -84
  244. package/dist/services/ThemeProvider.d.ts +0 -95
  245. package/dist/services/ThemeProvider.js +0 -334
  246. package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
  247. package/dist/services/defaultPersonalNeedsProfile.js +0 -26
  248. package/dist/services/pnp-standard-features.d.ts +0 -238
  249. package/dist/services/pnp-standard-features.js +0 -338
  250. package/dist/services/tts-control-events.d.ts +0 -13
  251. package/dist/services/tts-control-events.js +0 -7
  252. package/dist/tools/client.d.ts +0 -10
  253. package/dist/tools/client.js +0 -10
  254. package/dist/tools/internal.d.ts +0 -44
  255. package/dist/tools/internal.js +0 -39
  256. package/dist/utils/logger.d.ts +0 -6
  257. package/dist/utils/logger.js +0 -10
@@ -1,9 +1,9 @@
1
- import type { TTSConfig } from "./TTSService.js";
2
- import type { TextToSpeechToolProviderConfig } from "./tools-config-normalizer.js";
1
+ import type { SpeedRateBucket } from "@pie-players/pie-tts";
2
+ import type { TextToSpeechToolProviderConfig, ToolProviderConfig } from "./tools-config-normalizer.js";
3
3
  import { type SREMathSpeechOptions } from "./tts/math-speech.js";
4
+ import type { ToolkitTTSConfig } from "./tts/provider-options.js";
4
5
  export type TTSLayoutMode = "reserved-row" | "expanding-row" | "floating-overlay" | "left-aligned";
5
6
  export interface TTSHostToolbarLayout {
6
- mount: "before-buttons";
7
7
  controlsRow: {
8
8
  reserveSpace: boolean;
9
9
  expandWhenToolActive: boolean;
@@ -26,9 +26,10 @@ export interface NormalizedTTSSpeedOption {
26
26
  isDefault: boolean;
27
27
  }
28
28
  export interface TTSRuntimeSettings {
29
- backend?: "browser" | "polly" | "google" | "server";
29
+ /** `browser` speaks through the Web Speech API; `server` through a TTS server. */
30
+ backend?: "browser" | "server";
31
+ /** The service behind a `server` backend. */
30
32
  serverProvider?: "polly" | "google" | "custom";
31
- provider?: "polly" | "google" | "custom";
32
33
  engine?: "standard" | "neural";
33
34
  sampleRate?: number;
34
35
  format?: "mp3" | "ogg" | "pcm";
@@ -37,9 +38,23 @@ export interface TTSRuntimeSettings {
37
38
  rate?: number;
38
39
  pitch?: number;
39
40
  apiEndpoint?: string;
41
+ /**
42
+ * The host's locale, used for a read whose content names no language: it
43
+ * drives text normalization and segmentation, is sent as `language` on the
44
+ * `pie` transport and as `lang_id` on the `custom` transport when nothing
45
+ * names a language, and a server given no voice picks one for it. The
46
+ * content language a read resolves (markup `lang`, the tool's `language`,
47
+ * the toolkit's `content-language`, then `lang_id`) wins over it.
48
+ * `docs/architecture/internationalization.md#tts-language` is the contract.
49
+ */
40
50
  language?: string;
41
51
  transportMode?: "pie" | "custom";
42
52
  endpointMode?: "synthesizePath" | "rootPost";
53
+ /**
54
+ * The probe the server provider runs before it reports ready: `voices` reads
55
+ * the voices route, `endpoint` sends OPTIONS to the synthesis route, `none`
56
+ * probes nothing. Defaults to `voices` on a `server` backend.
57
+ */
43
58
  endpointValidationMode?: "voices" | "endpoint" | "none";
44
59
  includeAuthOnAssetFetch?: boolean;
45
60
  /** Origins trusted with the `Authorization` header on asset fetches. */
@@ -48,9 +63,19 @@ export interface TTSRuntimeSettings {
48
63
  credentials?: "omit" | "same-origin" | "include";
49
64
  /** Headers sent with every request to the TTS server. */
50
65
  headers?: Record<string, string>;
51
- validateEndpoint?: boolean;
66
+ /** Server-side caching, sent on the `custom` transport. */
52
67
  cache?: boolean;
53
- speedRate?: "slow" | "medium" | "fast";
68
+ /**
69
+ * Speed bucket sent on the `custom` transport; derived from `rate` when
70
+ * unset.
71
+ */
72
+ speedRate?: SpeedRateBucket;
73
+ /**
74
+ * The custom transport's locale, sent on every read in place of the content
75
+ * language. Where markup and the tool name no language it is also the read's
76
+ * content language, so text processing and catalog lookups follow it. Leave
77
+ * it unset to let content language reach the service.
78
+ */
54
79
  lang_id?: string;
55
80
  /**
56
81
  * Optional inline TTS speed buttons.
@@ -84,21 +109,16 @@ export interface TTSRuntimeSettings {
84
109
  /**
85
110
  * Options passed through to the provider. The fields derived from the
86
111
  * settings above, such as `locale` and the Polly engine, win over these.
112
+ * The `custom` transport reads the three typed keys; the settings of the
113
+ * same names win over them.
87
114
  */
88
- providerOptions?: Record<string, unknown>;
115
+ providerOptions?: {
116
+ speedRate?: SpeedRateBucket;
117
+ lang_id?: string;
118
+ cache?: boolean;
119
+ [option: string]: unknown;
120
+ };
89
121
  }
90
- export declare const normalizeTTSLayoutMode: (value: unknown, fallback?: TTSLayoutMode) => TTSLayoutMode;
91
- /** Legacy numeric helper defaults. Rendered controls add visible Normal separately. */
92
- export declare const DEFAULT_TTS_SPEED_OPTIONS: readonly number[];
93
- export declare const normalizeTTSSpeedOptionConfigs: (value: unknown) => TTSSpeedOption[];
94
- /**
95
- * Resolves inline toolbar speed options from host config.
96
- * - Omitted/non-array: default speed buttons.
97
- * - Empty array: hide speed buttons.
98
- * - Arrays that sanitize to no valid values: default speed buttons.
99
- * - 1.0× is never shown as a discrete speed button.
100
- */
101
- export declare const normalizeTTSSpeedOptions: (value: unknown) => number[];
102
122
  export declare const normalizeTTSSpeedControlOptions: (value: unknown) => NormalizedTTSSpeedOption[];
103
123
  export declare const formatTTSSpeedOptionsAsText: (values: number[]) => string;
104
124
  /**
@@ -107,17 +127,25 @@ export declare const formatTTSSpeedOptionsAsText: (values: number[]) => string;
107
127
  * - Non-empty text with no parseable finite numbers → same as invalid-only array config: defaults.
108
128
  */
109
129
  export declare const parseTTSSpeedOptionsFromText: (text: string) => number[];
110
- export declare const resolveTTSRuntimeSettings: (config: TextToSpeechToolProviderConfig | TTSRuntimeSettings | undefined) => TTSRuntimeSettings;
130
+ /**
131
+ * The runtime settings of a `textToSpeech` provider entry: its top-level keys
132
+ * with defaults applied, an unknown `layoutMode` resolved to `left-aligned`.
133
+ * `enabled` and the runtime `provider` object belong to the tool registration
134
+ * and are dropped.
135
+ */
136
+ export declare const resolveTTSRuntimeSettings: (config: TextToSpeechToolProviderConfig | ToolProviderConfig | TTSRuntimeSettings | undefined) => TTSRuntimeSettings & {
137
+ layoutMode: TTSLayoutMode;
138
+ };
111
139
  export declare const resolveTTSBackend: (config: TTSRuntimeSettings) => NonNullable<TTSRuntimeSettings["backend"]>;
112
- export declare const resolveRuntimeProvider: (config: TTSRuntimeSettings, backend: NonNullable<TTSRuntimeSettings["backend"]>) => TTSRuntimeSettings["serverProvider"];
113
- export declare const resolveTransportMode: (config: TTSRuntimeSettings, runtimeProvider: TTSRuntimeSettings["serverProvider"]) => NonNullable<TTSRuntimeSettings["transportMode"]>;
114
140
  /**
115
141
  * The provider configuration built from host settings: the contract's portable
116
142
  * fields plus the server adapter's, under the adapter's names.
117
143
  */
118
- export type RuntimeTTSConfig = Pick<TTSConfig, "voice" | "rate" | "pitch" | "providerOptions" | "mathTokenHighlighting"> & Pick<TTSRuntimeSettings, "apiEndpoint" | "language" | "transportMode" | "endpointMode" | "endpointValidationMode" | "includeAuthOnAssetFetch" | "assetOrigins" | "credentials" | "headers" | "validateEndpoint"> & {
144
+ export type RuntimeTTSConfig = Pick<ToolkitTTSConfig, "voice" | "rate" | "pitch" | "providerOptions" | "mathTokenHighlighting"> & Pick<TTSRuntimeSettings, "apiEndpoint" | "language" | "transportMode" | "endpointMode" | "endpointValidationMode" | "includeAuthOnAssetFetch" | "assetOrigins" | "credentials" | "headers"> & {
119
145
  provider?: TTSRuntimeSettings["serverProvider"];
120
146
  };
121
147
  export declare const buildRuntimeTTSConfig: (config: TTSRuntimeSettings) => RuntimeTTSConfig;
122
- export declare const resolveTTSLayoutMode: (config: TTSRuntimeSettings) => TTSLayoutMode;
123
- export declare const resolveTTSHostToolbarLayout: (config: TTSRuntimeSettings) => TTSHostToolbarLayout;
148
+ /** The toolbar layout hints for the layout mode of resolved settings. */
149
+ export declare const resolveTTSHostToolbarLayout: (config: {
150
+ layoutMode: TTSLayoutMode;
151
+ }) => TTSHostToolbarLayout;
@@ -6,26 +6,20 @@ const VALID_TTS_LAYOUT_MODES = new Set([
6
6
  "left-aligned",
7
7
  ]);
8
8
  const toRecord = (value) => value && typeof value === "object" ? value : {};
9
- const isServerBackend = (backend) => backend === "polly" || backend === "google" || backend === "server";
10
9
  const withDefault = (value, fallback) => value === undefined ? fallback : value;
11
- export const normalizeTTSLayoutMode = (value, fallback = "left-aligned") => typeof value === "string" &&
10
+ /** A custom server provider speaks the custom transport, as `ServerTTSProvider` does on its own. */
11
+ const defaultTransportMode = (config) => resolveTTSBackend(config) === "server" && config.serverProvider === "custom"
12
+ ? "custom"
13
+ : "pie";
14
+ const normalizeTTSLayoutMode = (value) => typeof value === "string" &&
12
15
  VALID_TTS_LAYOUT_MODES.has(value)
13
16
  ? value
14
- : fallback;
15
- /** Legacy numeric helper defaults. Rendered controls add visible Normal separately. */
16
- export const DEFAULT_TTS_SPEED_OPTIONS = Object.freeze([0.8, 1.25]);
17
+ : "left-aligned";
17
18
  const DEFAULT_TTS_SPEED_CONTROL_OPTIONS = Object.freeze([
18
19
  { rate: 0.8, label: "Slow", ariaLabel: "Slow speed" },
19
20
  { rate: 1, label: "Normal", ariaLabel: "Normal speed", default: true },
20
21
  { rate: 1.25, label: "Fast", ariaLabel: "Fast speed" },
21
22
  ]);
22
- const normalizeSpeedRate = (entry) => {
23
- if (typeof entry !== "number" || !Number.isFinite(entry) || entry <= 0) {
24
- return undefined;
25
- }
26
- const rounded = Math.round(entry * 100) / 100;
27
- return rounded === 1 ? undefined : rounded;
28
- };
29
23
  const normalizeControlSpeedRate = (entry) => {
30
24
  if (typeof entry !== "number" || !Number.isFinite(entry) || entry <= 0) {
31
25
  return undefined;
@@ -51,56 +45,6 @@ const normalizeSpeedAriaLabel = (label, ariaLabel, usedDefaultLabel) => {
51
45
  return ariaLabel;
52
46
  return `${label} ${ariaLabel}`;
53
47
  };
54
- const normalizeTTSSpeedOptionConfig = (entry) => {
55
- if (typeof entry === "number")
56
- return normalizeSpeedRate(entry);
57
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
58
- return undefined;
59
- const record = entry;
60
- const rate = normalizeSpeedRate(record.rate);
61
- if (rate === undefined)
62
- return undefined;
63
- const label = trimOptionalText(record.label);
64
- const ariaLabel = trimOptionalText(record.ariaLabel);
65
- return {
66
- rate,
67
- ...(label ? { label } : {}),
68
- ...(ariaLabel ? { ariaLabel } : {}),
69
- };
70
- };
71
- export const normalizeTTSSpeedOptionConfigs = (value) => {
72
- if (!Array.isArray(value))
73
- return [...DEFAULT_TTS_SPEED_OPTIONS];
74
- if (value.length === 0)
75
- return [];
76
- const dedupedRates = new Set();
77
- const normalized = [];
78
- for (const entry of value) {
79
- const option = normalizeTTSSpeedOptionConfig(entry);
80
- if (option === undefined)
81
- continue;
82
- const rate = typeof option === "number" ? option : option.rate;
83
- if (dedupedRates.has(rate))
84
- continue;
85
- dedupedRates.add(rate);
86
- normalized.push(option);
87
- }
88
- return normalized.length ? normalized : [...DEFAULT_TTS_SPEED_OPTIONS];
89
- };
90
- /**
91
- * Resolves inline toolbar speed options from host config.
92
- * - Omitted/non-array: default speed buttons.
93
- * - Empty array: hide speed buttons.
94
- * - Arrays that sanitize to no valid values: default speed buttons.
95
- * - 1.0× is never shown as a discrete speed button.
96
- */
97
- export const normalizeTTSSpeedOptions = (value) => {
98
- if (!Array.isArray(value))
99
- return [...DEFAULT_TTS_SPEED_OPTIONS];
100
- if (value.length === 0)
101
- return [];
102
- return normalizeTTSSpeedOptionConfigs(value).map((option) => typeof option === "number" ? option : option.rate);
103
- };
104
48
  export const normalizeTTSSpeedControlOptions = (value) => {
105
49
  const input = Array.isArray(value)
106
50
  ? value
@@ -117,11 +61,7 @@ export const normalizeTTSSpeedControlOptions = (value) => {
117
61
  if (rate === undefined || dedupedRates.has(rate))
118
62
  continue;
119
63
  dedupedRates.add(rate);
120
- const defaultLabel = rate === 1
121
- ? "Normal"
122
- : typeof entry === "number"
123
- ? formatSpeedLabel(rate)
124
- : formatSpeedLabel(rate);
64
+ const defaultLabel = rate === 1 ? "Normal" : formatSpeedLabel(rate);
125
65
  const label = typeof entry === "number"
126
66
  ? defaultLabel
127
67
  : trimOptionalText(record.label) || defaultLabel;
@@ -203,61 +143,42 @@ const applyRuntimeDefaults = (config) => {
203
143
  ...config,
204
144
  layoutMode: normalizeTTSLayoutMode(config.layoutMode),
205
145
  };
206
- const backend = config.backend || "browser";
207
- if (!isServerBackend(backend))
146
+ if (config.backend !== "server")
208
147
  return withLayoutDefaults;
209
148
  const withServerDefaults = {
210
149
  ...withLayoutDefaults,
211
150
  apiEndpoint: withDefault(withLayoutDefaults.apiEndpoint, "/api/tts"),
212
- transportMode: withDefault(withLayoutDefaults.transportMode, "pie"),
151
+ transportMode: withDefault(withLayoutDefaults.transportMode, defaultTransportMode(config)),
213
152
  endpointValidationMode: withDefault(withLayoutDefaults.endpointValidationMode, "voices"),
214
- validateEndpoint: withDefault(withLayoutDefaults.validateEndpoint, true),
215
153
  includeAuthOnAssetFetch: withDefault(withLayoutDefaults.includeAuthOnAssetFetch, false),
216
154
  rate: withDefault(withLayoutDefaults.rate, 1.0),
217
155
  language: withDefault(withLayoutDefaults.language, "en-US"),
218
156
  };
219
- if (backend === "polly") {
157
+ if (config.serverProvider === "polly") {
220
158
  return {
221
159
  ...withServerDefaults,
222
- defaultVoice: withDefault(withServerDefaults.defaultVoice, "Joanna"),
223
160
  engine: withDefault(withServerDefaults.engine, "neural"),
224
161
  format: withDefault(withServerDefaults.format, "mp3"),
225
162
  speechMarksMode: withDefault(withServerDefaults.speechMarksMode, "word+sentence"),
226
163
  };
227
164
  }
228
- if (backend === "google") {
229
- return {
230
- ...withServerDefaults,
231
- defaultVoice: withDefault(withServerDefaults.defaultVoice, "en-US-Wavenet-A"),
232
- };
233
- }
234
165
  return withServerDefaults;
235
166
  };
167
+ /**
168
+ * The runtime settings of a `textToSpeech` provider entry: its top-level keys
169
+ * with defaults applied, an unknown `layoutMode` resolved to `left-aligned`.
170
+ * `enabled` and the runtime `provider` object belong to the tool registration
171
+ * and are dropped.
172
+ */
236
173
  export const resolveTTSRuntimeSettings = (config) => {
237
- const configRecord = toRecord(config);
238
- const settingsRecord = toRecord(configRecord.settings);
239
- const { provider, ...merged } = { ...configRecord, ...settingsRecord };
240
- // A runtime provider object in `provider` is for the tool registration; the
241
- // runtime settings carry only a server provider id.
242
- return applyRuntimeDefaults({
243
- ...merged,
244
- ...(typeof provider === "string" ? { provider } : {}),
245
- });
174
+ const { enabled: _enabled, provider: _provider, ...settings } = toRecord(config);
175
+ return applyRuntimeDefaults(settings);
246
176
  };
247
177
  export const resolveTTSBackend = (config) => config.backend || "browser";
248
- export const resolveRuntimeProvider = (config, backend) => {
249
- if (backend === "polly" || backend === "google")
250
- return backend;
251
- if (backend === "server") {
252
- return config.serverProvider || config.provider;
253
- }
254
- return config.serverProvider || config.provider;
255
- };
256
- export const resolveTransportMode = (config, runtimeProvider) => config.transportMode || (runtimeProvider === "custom" ? "custom" : "pie");
257
178
  export const buildRuntimeTTSConfig = (config) => {
258
- const backend = resolveTTSBackend(config);
259
- const runtimeProvider = resolveRuntimeProvider(config, backend);
260
- const transportMode = resolveTransportMode(config, runtimeProvider);
179
+ const runtimeProvider = resolveTTSBackend(config) === "server" ? config.serverProvider : undefined;
180
+ const polly = runtimeProvider === "polly";
181
+ const transportMode = config.transportMode || defaultTransportMode(config);
261
182
  const mathSpeech = normalizeSREMathSpeechOptions(config.mathSpeech);
262
183
  const runtimeConfig = {
263
184
  voice: config.defaultVoice,
@@ -266,16 +187,16 @@ export const buildRuntimeTTSConfig = (config) => {
266
187
  providerOptions: {
267
188
  ...toRecord(config.providerOptions),
268
189
  ...(config.language ? { locale: config.language } : {}),
269
- ...(backend === "polly" && config.engine
190
+ ...(polly && config.engine
270
191
  ? { engine: config.engine }
271
192
  : {}),
272
- ...(backend === "polly" && typeof config.sampleRate === "number"
193
+ ...(polly && typeof config.sampleRate === "number"
273
194
  ? { sampleRate: config.sampleRate }
274
195
  : {}),
275
- ...(backend === "polly" && config.format
196
+ ...(polly && config.format
276
197
  ? { format: config.format }
277
198
  : {}),
278
- ...(backend === "polly"
199
+ ...(polly
279
200
  ? {
280
201
  speechMarkTypes: config.speechMarksMode === "word+sentence"
281
202
  ? ["word", "sentence"]
@@ -303,7 +224,6 @@ export const buildRuntimeTTSConfig = (config) => {
303
224
  assetOrigins: config.assetOrigins,
304
225
  credentials: config.credentials,
305
226
  headers: config.headers,
306
- validateEndpoint: config.validateEndpoint,
307
227
  // Toolkit-level highlight setting carried through the config channel
308
228
  // (like apiEndpoint/transportMode); consumed by the highlight pipeline,
309
229
  // ignored by providers. Only forwarded when set so the pipeline default
@@ -314,13 +234,11 @@ export const buildRuntimeTTSConfig = (config) => {
314
234
  };
315
235
  return runtimeConfig;
316
236
  };
317
- export const resolveTTSLayoutMode = (config) => normalizeTTSLayoutMode(config.layoutMode);
237
+ /** The toolbar layout hints for the layout mode of resolved settings. */
318
238
  export const resolveTTSHostToolbarLayout = (config) => {
319
- const layoutMode = resolveTTSLayoutMode(config);
320
- switch (layoutMode) {
239
+ switch (config.layoutMode) {
321
240
  case "reserved-row":
322
241
  return {
323
- mount: "before-buttons",
324
242
  controlsRow: {
325
243
  reserveSpace: true,
326
244
  expandWhenToolActive: false,
@@ -331,7 +249,6 @@ export const resolveTTSHostToolbarLayout = (config) => {
331
249
  };
332
250
  case "expanding-row":
333
251
  return {
334
- mount: "before-buttons",
335
252
  controlsRow: {
336
253
  reserveSpace: false,
337
254
  expandWhenToolActive: true,
@@ -342,7 +259,6 @@ export const resolveTTSHostToolbarLayout = (config) => {
342
259
  };
343
260
  case "floating-overlay":
344
261
  return {
345
- mount: "before-buttons",
346
262
  controlsRow: {
347
263
  reserveSpace: false,
348
264
  expandWhenToolActive: false,
@@ -354,7 +270,6 @@ export const resolveTTSHostToolbarLayout = (config) => {
354
270
  case "left-aligned":
355
271
  default:
356
272
  return {
357
- mount: "before-buttons",
358
273
  controlsRow: {
359
274
  reserveSpace: false,
360
275
  expandWhenToolActive: false,
@@ -3,7 +3,7 @@
3
3
  * profile.
4
4
  *
5
5
  * Two independent halves, and a capability is in play only when both answer yes:
6
- * policy granted one of its support ids, and its own `requiresAuthoredContent`
6
+ * policy granted its support id, and its own `requiresAuthoredContent`
7
7
  * found the resource in this entity's catalogs. Neither implies the other — a
8
8
  * learner with an accommodation still sees nothing on an item carrying no
9
9
  * resource, and an item carrying one shows nothing to a learner without the
@@ -30,13 +30,11 @@
30
30
  */
31
31
  import type { ToolRegistration } from "../services/ToolRegistry.js";
32
32
  import type { CatalogOwnerSnapshot } from "../services/AccessibilityCatalogResolver.js";
33
- /** What policy answered about one feature id. */
33
+ /** What policy answered about one capability's support id. */
34
34
  export type ContentCapabilityPolicy = {
35
35
  outcome: "granted";
36
- /** The support id that was granted — a capability may declare several. */
37
- featureId: string;
38
36
  /** Feature parameters carried by the decision, if any. */
39
- parameters?: unknown;
37
+ parameters?: Record<string, unknown>;
40
38
  }
41
39
  /**
42
40
  * No source granted it and none denied it. A capability declaring
@@ -61,13 +59,13 @@ export type ContentCapabilityPhase = "policy" | "content";
61
59
  export interface ResolvedContentCapability {
62
60
  registration: ToolRegistration;
63
61
  /**
64
- * The granted support id, or `""` when the capability resolved without a
65
- * grant. Passed through to the render context unchanged, so a capability that
62
+ * Whether policy granted the capability; `false` when it resolved from content
63
+ * alone. Passed through to the render context unchanged, so a capability that
66
64
  * serves both an authored-presentation case and an accommodation can still
67
65
  * tell them apart at render time.
68
66
  */
69
- featureId: string;
70
- parameters?: unknown;
67
+ granted: boolean;
68
+ parameters?: Record<string, unknown>;
71
69
  /** Whatever the capability's own `resolve` returned; never inspected here. */
72
70
  content: unknown;
73
71
  }
@@ -81,7 +79,7 @@ export interface ResolveContentCapabilitiesArgs {
81
79
  /** The entity's cards, or `null` when no resolver is available. */
82
80
  catalogs: CatalogOwnerSnapshot | null;
83
81
  /**
84
- * Policy's answer about one feature id, in three states.
82
+ * Policy's answer about one support id, which is a tool id, in three states.
85
83
  *
86
84
  * Granting requires a documented need, so an unconfigured feature is
87
85
  * `"silent"`, never granted. What the third state buys is the distinction
@@ -89,7 +87,7 @@ export interface ResolveContentCapabilitiesArgs {
89
87
  * something, and a capability allowed to answer from content alone must not
90
88
  * treat that as nobody having spoken.
91
89
  */
92
- policyFor: (featureId: string) => ContentCapabilityPolicy;
90
+ policyFor: (supportId: string) => ContentCapabilityPolicy;
93
91
  /**
94
92
  * Report a capability that threw. It is dropped either way; this is how a
95
93
  * caller surfaces it as its own recoverable warning rather than letting one
@@ -3,7 +3,7 @@
3
3
  * profile.
4
4
  *
5
5
  * Two independent halves, and a capability is in play only when both answer yes:
6
- * policy granted one of its support ids, and its own `requiresAuthoredContent`
6
+ * policy granted its support id, and its own `requiresAuthoredContent`
7
7
  * found the resource in this entity's catalogs. Neither implies the other — a
8
8
  * learner with an accommodation still sees nothing on an item carrying no
9
9
  * resource, and an item carrying one shows nothing to a learner without the
@@ -28,51 +28,15 @@
28
28
  * a capability interprets its own cards, and the resolution owns only the
29
29
  * two-halves rule and its one documented exception.
30
30
  */
31
- /** The support ids a capability answers to, defaulting to its own id. */
32
- const supportIdsOf = (registration) => registration.pnpSupportIds?.length
33
- ? registration.pnpSupportIds
34
- : [registration.toolId];
35
- /**
36
- * Everything policy has to say about one capability: a grant, an off switch, or
37
- * nothing.
38
- *
39
- * Denial is checked ahead of a grant on each id rather than after the scan,
40
- * because the two can only disagree when a host blocked one of a capability's ids
41
- * while a profile granted another, and there the off switch is the later, more
42
- * specific statement about this delivery.
43
- *
44
- * A host gate names *capabilities*, so the tool id is probed too when it is not
45
- * already a declared support id — otherwise a capability whose id differs from
46
- * its support ids would slip a host block. That probe is gate-only: a grant on
47
- * the tool id is ignored, or blocking would double as a second way to switch a
48
- * capability on.
49
- */
50
- function policyForCapability(registration, args) {
51
- const supportIds = supportIdsOf(registration);
52
- for (const supportId of supportIds) {
53
- const answer = args.policyFor(supportId);
54
- if (answer.outcome === "denied")
55
- return { grant: null, denied: true };
56
- if (answer.outcome === "granted")
57
- return { grant: answer, denied: false };
58
- }
59
- if (supportIds.includes(registration.toolId)) {
60
- return { grant: null, denied: false };
61
- }
62
- return {
63
- grant: null,
64
- denied: args.policyFor(registration.toolId).outcome === "denied",
65
- };
66
- }
67
31
  function resolveOne(registration, args) {
68
32
  let grant = null;
69
33
  try {
70
- const answer = policyForCapability(registration, args);
71
- // Nothing reopens a host denial — not a grant it outranked, and not the
72
- // content exception below.
73
- if (answer.denied)
34
+ const answer = args.policyFor(registration.toolId);
35
+ // Nothing reopens a host denial, not even the content exception below.
36
+ if (answer.outcome === "denied")
74
37
  return null;
75
- grant = answer.grant;
38
+ if (answer.outcome === "granted")
39
+ grant = answer;
76
40
  }
77
41
  catch (error) {
78
42
  args.onError?.(registration, "policy", error);
@@ -92,13 +56,12 @@ function resolveOne(registration, args) {
92
56
  return null;
93
57
  return {
94
58
  registration,
95
- featureId: grant.featureId,
59
+ granted: true,
96
60
  parameters: grant.parameters,
97
61
  content: null,
98
62
  };
99
63
  }
100
64
  const context = {
101
- featureId: grant?.featureId ?? "",
102
65
  parameters: grant?.parameters,
103
66
  catalogs: args.catalogs,
104
67
  granted: Boolean(grant),
@@ -117,7 +80,7 @@ function resolveOne(registration, args) {
117
80
  return null;
118
81
  return {
119
82
  registration,
120
- featureId: context.featureId,
83
+ granted: context.granted,
121
84
  parameters: context.parameters,
122
85
  content,
123
86
  };
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Tool registration — the stable entry for tool authors: writing and rendering a
3
+ * `ToolRegistration`, and the runtime contract a tool element is written against.
4
+ *
5
+ * A capability package writes a registration with it: the registration contract,
6
+ * the context predicates a tool answers `isVisibleInContext` with, scoped ids,
7
+ * element creation, the toolbar button and overlay helpers, the provider contract
8
+ * a descriptor creates, and the TTS provider with its config resolution. A
9
+ * renderer puts registrations on screen with it: `createToolSurfaceHost` mounts
10
+ * and reconciles surfaces, and `resolveContentCapabilities` asks the
11
+ * grant-and-content question without a coordinator. A tool element connects to
12
+ * the runtime with it: the runtime, shell and region-scope contexts, the services
13
+ * they carry, coordinator registration, the reading scope of the content it reads
14
+ * or annotates, and read-aloud coordination.
15
+ *
16
+ * The composition layer (`@pie-players/pie-default-tool-loaders`), the packaged
17
+ * tools and the section player's tool panels are written against it, so a host's
18
+ * own tool uses the mechanism ours use. Its values are complete, so a tool
19
+ * package never imports the root entry, which carries what hosts and players
20
+ * import. A name the root also carries appears here only where a package imports
21
+ * it from here.
22
+ */
23
+ export type { HostedToolContext, HostedToolSize, ToolContentDependencyContext, ToolModuleLoader, ToolProviderDescriptor, ToolRegistration, ToolRenderElement, ToolSurfaceRenderContext, ToolSurfaceRenderResult, ToolSurfaceServices, ToolToolbarButtonDefinition, ToolToolbarRenderResult, ToolbarContext, } from "../services/ToolRegistry.js";
24
+ export { ToolRegistry } from "../services/ToolRegistry.js";
25
+ export { resolveToolRegistrationName } from "../services/ToolRegistry.js";
26
+ export type { ToolFailurePhase } from "../services/tool-failure.js";
27
+ export { reportToolFailure } from "../services/tool-failure.js";
28
+ export type { CatalogOwnerSnapshot } from "../services/AccessibilityCatalogResolver.js";
29
+ export type { ToolSelectionAction, ToolSelectionContext, } from "../services/selection-action.js";
30
+ export { resolveFallbackToolIcon } from "../services/tool-icons.js";
31
+ export type { ContentCapabilityPhase, ContentCapabilityPolicy, ResolveContentCapabilitiesArgs, ResolvedContentCapability, } from "./content-capability-resolution.js";
32
+ export { resolveContentCapabilities } from "./content-capability-resolution.js";
33
+ export type { ToolSurfaceHost, ToolSurfaceHostInput, ToolSurfaceHostOptions, ToolSurfaceHostSnapshot, ToolSurfaceScope, } from "./tool-surface-host.js";
34
+ export { createToolSurfaceHost } from "./tool-surface-host.js";
35
+ export type { ToolContext } from "../services/tool-context.js";
36
+ export { hasChoiceInteraction, hasMathContent, hasReadableText, hasSpokenContent, hasScienceContent, } from "../services/tool-context.js";
37
+ export type { ParsedToolInstanceId } from "../services/tool-instance-id.js";
38
+ export { createScopedToolId, parseScopedToolId, } from "../services/tool-instance-id.js";
39
+ export type { ToolComponentFactory, ToolComponentFactoryMap, ToolComponentOverrides, ToolTagMap, } from "./tool-tag-map.js";
40
+ export { createToolElement, resolveToolTag } from "./tool-tag-map.js";
41
+ export { applyOverlaySurface, createScopedVisibilityBinding, syncButtonAndOverlayVisibility, TOOL_ACTIVE_CHANGE_EVENT, } from "./registrations/toolbar-registration-helpers.js";
42
+ export type { HighlightCoordinatorApi, ToolCoordinatorApi, ToolkitCoordinatorApi, TtsServiceApi, } from "../services/interfaces.js";
43
+ export type { AssessmentToolkitRegionScopeContext, AssessmentToolkitRuntimeContext, AssessmentToolkitShellContext, } from "../context/assessment-toolkit-context.js";
44
+ export { connectToolRegionScopeContext, connectToolRuntimeContext, connectToolShellContext, createToolCoordinatorRegistration, type ToolCoordinatorRegistration, } from "../runtime/tool-host-contract.js";
45
+ export { ZIndexLayer } from "../services/ToolCoordinator.js";
46
+ export { HighlightColor, HighlightCoordinator, } from "../services/HighlightCoordinator.js";
47
+ export type { CatalogLookupContext } from "../services/AccessibilityCatalogResolver.js";
48
+ export { catalogContextForShell, catalogContextHolding, type CatalogRuntimeScope, } from "../runtime/catalog-context.js";
49
+ export { findShellScopeHost, resolveContentRegion, } from "../runtime/content-region.js";
50
+ export { composedClosest, composedContains, flatTextContent, isShadowRootNode, retargetToTree, } from "../services/tts/flat-tree.js";
51
+ export type { ToolPlacementLevel } from "../services/tools-config-normalizer.js";
52
+ export type { CalculatorToolProviderConfig, TextToSpeechToolProviderConfig, ToolProviderConfig, } from "../services/tools-config-normalizer.js";
53
+ export type { ToolProviderApi } from "../services/tool-providers/ToolProviderApi.js";
54
+ export { TTSToolProvider } from "../services/tool-providers/index.js";
55
+ export type { NormalizedTTSSpeedOption, TTSLayoutMode, TTSSpeedOption, } from "../services/tts-runtime-config.js";
56
+ export { buildRuntimeTTSConfig, formatTTSSpeedOptionsAsText, normalizeTTSSpeedControlOptions, parseTTSSpeedOptionsFromText, resolveTTSHostToolbarLayout, resolveTTSRuntimeSettings, } from "../services/tts-runtime-config.js";
57
+ export { bindTtsAudioHandoff, pauseTtsForMediaAudio, } from "../services/audio-handoff.js";
58
+ export { isTTSStartFailure } from "../services/tts/start-failure.js";
59
+ export { browserVoiceMatchesLanguage, findBrowserVoice, waitForBrowserVoices, } from "../services/tts/browser-provider.js";
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Tool registration — the stable entry for tool authors: writing and rendering a
3
+ * `ToolRegistration`, and the runtime contract a tool element is written against.
4
+ *
5
+ * A capability package writes a registration with it: the registration contract,
6
+ * the context predicates a tool answers `isVisibleInContext` with, scoped ids,
7
+ * element creation, the toolbar button and overlay helpers, the provider contract
8
+ * a descriptor creates, and the TTS provider with its config resolution. A
9
+ * renderer puts registrations on screen with it: `createToolSurfaceHost` mounts
10
+ * and reconciles surfaces, and `resolveContentCapabilities` asks the
11
+ * grant-and-content question without a coordinator. A tool element connects to
12
+ * the runtime with it: the runtime, shell and region-scope contexts, the services
13
+ * they carry, coordinator registration, the reading scope of the content it reads
14
+ * or annotates, and read-aloud coordination.
15
+ *
16
+ * The composition layer (`@pie-players/pie-default-tool-loaders`), the packaged
17
+ * tools and the section player's tool panels are written against it, so a host's
18
+ * own tool uses the mechanism ours use. Its values are complete, so a tool
19
+ * package never imports the root entry, which carries what hosts and players
20
+ * import. A name the root also carries appears here only where a package imports
21
+ * it from here.
22
+ */
23
+ export { ToolRegistry } from "../services/ToolRegistry.js";
24
+ // A registration's own display name in the interface locale. A tool window's
25
+ // title is the registration's name, so the shell needs the same `nameKey`-then-
26
+ // `name` precedence the toolbar uses rather than the raw English field.
27
+ export { resolveToolRegistrationName } from "../services/ToolRegistry.js";
28
+ export { reportToolFailure } from "../services/tool-failure.js";
29
+ // So a gateway button and the toolbar button for the same tool draw one icon.
30
+ export { resolveFallbackToolIcon } from "../services/tool-icons.js";
31
+ export { resolveContentCapabilities } from "./content-capability-resolution.js";
32
+ export { createToolSurfaceHost } from "./tool-surface-host.js";
33
+ export { hasChoiceInteraction, hasMathContent, hasReadableText, hasSpokenContent, hasScienceContent, } from "../services/tool-context.js";
34
+ export { createScopedToolId, parseScopedToolId, } from "../services/tool-instance-id.js";
35
+ export { createToolElement, resolveToolTag } from "./tool-tag-map.js";
36
+ // Toolbar button/overlay wiring shared by every toolbar-toggle registration,
37
+ // and the event a tool element announces its own active state with.
38
+ export { applyOverlaySurface, createScopedVisibilityBinding, syncButtonAndOverlayVisibility, TOOL_ACTIVE_CHANGE_EVENT, } from "./registrations/toolbar-registration-helpers.js";
39
+ export { connectToolRegionScopeContext, connectToolRuntimeContext, connectToolShellContext, createToolCoordinatorRegistration, } from "../runtime/tool-host-contract.js";
40
+ export { ZIndexLayer } from "../services/ToolCoordinator.js";
41
+ export { HighlightColor, HighlightCoordinator, } from "../services/HighlightCoordinator.js";
42
+ export { catalogContextForShell, catalogContextHolding, } from "../runtime/catalog-context.js";
43
+ export { findShellScopeHost, resolveContentRegion, } from "../runtime/content-region.js";
44
+ export { composedClosest, composedContains, flatTextContent, isShadowRootNode, retargetToTree, } from "../services/tts/flat-tree.js";
45
+ // The TTS provider stays here because it is written against the `pie-tts`
46
+ // contract package, which the toolkit's own `TTSService` also depends on.
47
+ export { TTSToolProvider } from "../services/tool-providers/index.js";
48
+ export { buildRuntimeTTSConfig, formatTTSSpeedOptionsAsText, normalizeTTSSpeedControlOptions, parseTTSSpeedOptionsFromText, resolveTTSHostToolbarLayout, resolveTTSRuntimeSettings, } from "../services/tts-runtime-config.js";
49
+ // Read-aloud coordination for a tool that plays or controls speech: pausing
50
+ // speech while a media element plays, recognising a start failure the TTS
51
+ // service reports, and choosing a browser voice for a language once the browser
52
+ // has published its voices.
53
+ export { bindTtsAudioHandoff, pauseTtsForMediaAudio, } from "../services/audio-handoff.js";
54
+ export { isTTSStartFailure } from "../services/tts/start-failure.js";
55
+ export { browserVoiceMatchesLanguage, findBrowserVoice, waitForBrowserVoices, } from "../services/tts/browser-provider.js";