@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
package/dist/index.js CHANGED
@@ -6,58 +6,28 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- export { assessmentToolkitHostRuntimeContext, assessmentToolkitRegionScopeContext, assessmentToolkitRuntimeContext, assessmentToolkitShellContext, } from "./context/assessment-toolkit-context.js";
10
- export { connectAssessmentToolkitHostRuntimeContext, connectAssessmentToolkitRegionScopeContext, connectAssessmentToolkitRuntimeContext, connectAssessmentToolkitShellContext, } from "./context/runtime-context-consumer.js";
11
- export { catalogOwnerContextFor, catalogSourceSignature, } from "./services/catalog-owner.js";
12
- export { PIE_INTERNAL_CONTENT_LOADED_EVENT, PIE_INTERNAL_FORMATIVE_ACTION_EVENT, PIE_INTERNAL_ITEM_SESSION_CHANGED_EVENT, PIE_INTERNAL_ITEM_PLAYER_ERROR_EVENT, PIE_INTERNAL_MEDIA_TIME_SOURCE_EVENT, PIE_ITEM_SESSION_CHANGED_EVENT, PIE_REGISTER_EVENT, PIE_UNREGISTER_EVENT, } from "./runtime/registration-events.js";
13
- export { connectToolRegionScopeContext, connectToolRuntimeContext, connectToolShellContext, createCrossBoundaryEvent, createToolCoordinatorRegistration, dispatchCrossBoundaryEvent, isContextValueDefined, } from "./runtime/tool-host-contract.js";
14
- export { AccessibilityCatalogResolver, catalogCardForm, isKnownCatalogType, KNOWN_CATALOG_TYPES, } from "./services/AccessibilityCatalogResolver.js";
15
- // Context Variable Store (QTI 3.0 Context Declarations)
16
- export { ContextVariableStore } from "./services/ContextVariableStore.js";
9
+ export { catalogOwnerContextFor, } from "./services/catalog-owner.js";
10
+ export { PIE_INTERNAL_FORMATIVE_ACTION_EVENT, PIE_INTERNAL_ITEM_SESSION_CHANGED_EVENT, PIE_INTERNAL_MEDIA_TIME_SOURCE_EVENT, PIE_ITEM_SESSION_CHANGED_EVENT, } from "./runtime/registration-events.js";
11
+ export { createShellScope, } from "./runtime/shell-scope.js";
12
+ // A shell's translation of its player's events into the runtime's, shared by the
13
+ // section player's passage shell and `<pie-item-scope>`.
14
+ export { createShellEventBridge, } from "./runtime/shell-event-bridge.js";
15
+ export { connectToolRuntimeContext, dispatchCrossBoundaryEvent, } from "./runtime/tool-host-contract.js";
16
+ export { AccessibilityCatalogResolver } from "./services/AccessibilityCatalogResolver.js";
17
17
  // Element Tool State Store (Element-level ephemeral tool state)
18
- export { ElementToolStateStore } from "./services/ElementToolStateStore.js";
18
+ export { ElementToolStateStore, } from "./services/ElementToolStateStore.js";
19
19
  export { HighlightColor, HighlightCoordinator, HighlightType, } from "./services/HighlightCoordinator.js";
20
- export { RangeSerializer } from "./services/RangeSerializer.js";
21
- export { I18nService } from "./services/I18nService.js";
22
20
  export { ToolRegistry } from "./services/ToolRegistry.js";
23
- export { DEFAULT_TOOL_REQUEST_LEVEL } from "./services/tool-request.js";
24
- export { extractTextContent, hasChoiceInteraction, hasMathContent, hasReadableText, isAssessmentContext, isElementContext, isItemContext, isPassageContext, isRubricContext, isSectionContext, } from "./services/tool-context.js";
25
- export { DEFAULT_TOOL_PLACEMENT } from "./services/tool-config-defaults.js";
21
+ export { hasReadableText, hasSpokenContent, } from "./services/tool-context.js";
26
22
  export { createToolsConfig } from "./services/create-tools-config.js";
27
- export { createEmptyPersonalNeedsProfile } from "./services/defaultPersonalNeedsProfile.js";
28
- export { createToolElement, resolveToolTag, toToolIdFromTag, } from "./tools/tool-tag-map.js";
29
- // QTI 3.0 Standard Access Features
30
- export { ALL_STANDARD_ACCESS_FEATURES, EXAMPLE_PNP_CONFIGURATIONS, getFeatureCategory, getFeaturesInCategory, isStandardAccessFeature, QTI_STANDARD_ACCESS_FEATURES, } from "./services/pnp-standard-features.js";
31
- // Media-bearing catalog cards: the generic half, shared by every card form that
32
- // references a recording rather than carrying text. Owned by
33
- // `@pie-players/pie-players-shared/media`, which an element can import without
34
- // this package; re-exported here for toolkit consumers.
35
- export { applyMediaFragment, enforceMediaFragment, isSafeMediaSrc, isUnsupportedMediaAssetVersion, normalizeMediaFragment, normalizeMediaSources, SUPPORTED_MEDIA_ASSET_VERSION, trimmedOrUndefined, } from "@pie-players/pie-players-shared/media";
36
- export { resolveSpokenAudioMedia, SPOKEN_CATALOG_TYPE, } from "./services/spoken-audio-cards.js";
37
23
  export { SSMLExtractor } from "./services/SSMLExtractor.js";
38
- export { ThemeProvider } from "./services/ThemeProvider.js";
39
24
  // Tool Coordinator
40
- export { ToolCoordinator, ZIndexLayer } from "./services/ToolCoordinator.js";
25
+ export { ZIndexLayer } from "./services/ToolCoordinator.js";
41
26
  export { ToolkitCoordinator } from "./services/ToolkitCoordinator.js";
42
- export { formatFrameworkErrorForConsole, frameworkErrorFromToolConfigDiagnostics, frameworkErrorFromUnknown, toFrameworkErrorModel, } from "./services/framework-error.js";
43
- export { isExternalIconUrl, isInlineSvgIcon, isToolbarLinkItem, isValidToolbarItemShape, } from "./services/toolbar-items.js";
44
- export { normalizeToolsConfig, normalizeToolAlias, normalizeToolList, parseToolList, } from "./services/tools-config-normalizer.js";
45
- export { isHostDeniedFeature } from "./policy/core/feature-decision.js";
46
- export { frameworkErrorFromToolConfigValidation, normalizeAndValidateToolsConfig, } from "./services/tool-config-validation.js";
47
- export { createScopedToolId, parseScopedToolId, toOverlayToolId, } from "./services/tool-instance-id.js";
27
+ export { frameworkErrorFromUnknown, toFrameworkErrorModel, } from "./services/framework-error.js";
28
+ export { createScopedToolId } from "./services/tool-instance-id.js";
29
+ // Text-to-Speech Service
48
30
  export { PlaybackState, TTSService } from "./services/TTSService.js";
49
- export { PIE_TTS_CONTROL_HANDOFF_EVENT, } from "./services/tts-control-events.js";
50
- export { bindTtsAudioHandoff, pauseTtsForMediaAudio, } from "./services/audio-handoff.js";
51
31
  export { BrowserTTSProvider } from "./services/tts/browser-provider.js";
52
- export { DEFAULT_TTS_SPEED_OPTIONS, formatTTSSpeedOptionsAsText, normalizeTTSLayoutMode, normalizeTTSSpeedControlOptions, normalizeTTSSpeedOptionConfigs, normalizeTTSSpeedOptions, parseTTSSpeedOptionsFromText, resolveTTSHostToolbarLayout, resolveTTSLayoutMode, resolveTTSRuntimeSettings, } from "./services/tts-runtime-config.js";
53
- export { createFetchItemLoader, createLoadItem, ItemLoadError, } from "./item-loader.js";
54
- export { createMemoryStorage, createTestAttemptSessionIdentifier, createNewTestAttemptSession, getBrowserLocalStorage, getOrCreateAnonymousDeviceId, getTestAttemptSessionStorageKey, loadTestAttemptSession, saveTestAttemptSession, setCurrentPosition, upsertItemSessionFromPieSessionChange, upsertVisitedItem, } from "./attempt/TestSession.js";
32
+ export { createNewTestAttemptSession, setCurrentPosition, toItemSessionsRecord, upsertItemSessionFromPieSessionChange, upsertVisitedItem, } from "./attempt/TestSession.js";
55
33
  export { createNewAssessmentSession, setCurrentSectionPosition, upsertSectionSession, } from "./attempt/AssessmentSession.js";
56
- export { buildActivitySessionItemUpdate, buildActivitySessionPatchFromTestAttemptSession, mapActivityToTestAttemptSession, toItemSessionsRecord, } from "./attempt/adapters/activity-to-test-attempt-session.js";
57
- // Section Player - Use @pie-players/pie-section-player web component
58
- // ============================================================================
59
- // Shared Components
60
- // ============================================================================
61
- // ItemToolBar custom element registration helper is exported via package.json exports field
62
- // Import using: import '@pie-players/pie-assessment-toolkit/components/item-toolbar-element';
63
- // PieAssessmentToolkit custom element registration helper is exported via package.json exports field
@@ -36,7 +36,7 @@ export interface PolicySourceProvenanceEntry {
36
36
  * Custom precedence value used for the decision log. Defaults to
37
37
  * `100 + sourceIndex` (engine-assigned) when `undefined`. Sources
38
38
  * MAY override only if they know what they are doing — overriding
39
- * to a value `<= 6` lets the source masquerade as a PNP/profile rule and
39
+ * to a value `<= 8` lets the source masquerade as a PNP/profile rule and
40
40
  * is generally a bug.
41
41
  */
42
42
  precedence?: number;
@@ -57,7 +57,7 @@ export interface PolicySourceResult {
57
57
  decisions?: PolicySourceProvenanceEntry[];
58
58
  }
59
59
  export interface PolicySource {
60
- /** Stable identifier — used for `custom.${id}` source tags. */
60
+ /** Stable identifier, recorded as `customSourceId` on the decisions and diagnostics it causes. */
61
61
  readonly id: string;
62
62
  refine(context: PolicySourceDecisionContext): PolicySourceResult;
63
63
  }
@@ -3,43 +3,40 @@
3
3
  * `docs/tools-and-accomodations/architecture.md`.
4
4
  *
5
5
  * Wraps `composeDecision(...)` with engine-instance state:
6
- * - bound inputs (`tools`, `assessment`, `currentItemRef`, ...)
6
+ * - bound inputs (`tools`, `assessment`, `pnpEnforcement`) and the
7
+ * settings of the mounted items
7
8
  * - registered custom `PolicySource`s
8
9
  * - `onPolicyChange` subscriber bus
9
10
  * - `dispose()` clean-up
10
11
  *
11
12
  * The class has no DOM dependency and no Svelte runes. It is safe to
12
13
  * instantiate inside a worker, in a Node test, or inside a CE
13
- * connectedCallback. The Svelte context glue (`TOOL_POLICY_ENGINE_KEY`)
14
- * lives in `engine-context.ts`.
15
- *
16
- * PR 1 ships the engine *without callers*. PR 2 wires it into
17
- * `ToolkitCoordinator`. PR 3 switches `<pie-item-toolbar>` over.
14
+ * connectedCallback. `ToolkitCoordinator` owns the instance, and
15
+ * `<pie-item-toolbar>` reads its decisions through the coordinator.
18
16
  */
19
- import type { AssessmentEntity, AssessmentItemRef } from "@pie-players/pie-players-shared/types";
20
- import type { CanonicalToolsConfig, ToolPlacementLevel } from "../../services/tools-config-normalizer.js";
17
+ import type { AssessmentEntity, ItemSettings, ToolParametersFor } from "@pie-players/pie-players-shared/types";
18
+ import type { CanonicalToolsConfig, PnpEnforcementMode, ToolPlacementLevel } from "../../services/tools-config-normalizer.js";
21
19
  import type { ToolRegistry } from "../../services/ToolRegistry.js";
22
- import type { ToolPolicyDecision, ToolPolicyDecisionRequest } from "./decision-types.js";
20
+ import type { ToolPolicyDecision, ToolPolicyDecisionRequest, ToolPolicyDiagnostic, ToolScope } from "./decision-types.js";
23
21
  import type { PolicySource } from "./PolicySource.js";
24
22
  import type { FeaturePolicyDecision } from "./feature-decision.js";
25
- export type PnpEnforcementMode = "on" | "off";
23
+ export type { PnpEnforcementMode };
26
24
  export interface ToolPolicyEngineInputs {
27
25
  tools?: CanonicalToolsConfig | null;
28
26
  assessment?: AssessmentEntity | null;
29
- currentItemRef?: AssessmentItemRef | null;
30
27
  /**
31
- * Explicit PNP/profile override. When omitted (or `undefined`), the engine
32
- * defaults to {@link resolveDefaultPnpEnforcement} over the bound
33
- * `assessment` and `currentItemRef`: `"on"` if they carry any
34
- * PNP/profile policy material (PNP, district policy, test
35
- * administration, item-level required/restricted/parameters),
28
+ * Explicit PNP/profile override; `null` or omitted is auto-mode. Auto-mode
29
+ * resolves per decision through {@link resolveDefaultPnpEnforcement}: `"on"`
30
+ * when the bound `assessment` carries PNP/profile policy material (PNP,
31
+ * district policy, test administration), and for a decision scoped to an item
32
+ * also when that item's settings require or restrict a tool;
36
33
  * `"off"` otherwise. `tests/policy/pnp-default-on.test.ts` locks the rule.
37
34
  *
38
35
  * Hosts that want to force a mode pass `"on"` or `"off"`
39
36
  * explicitly. Embedded under `<pie-section-player-*>` the preferred
40
37
  * override flows through `runtime.tools.pnpEnforcement`.
41
38
  */
42
- pnpEnforcement?: PnpEnforcementMode;
39
+ pnpEnforcement?: PnpEnforcementMode | null;
43
40
  }
44
41
  export interface ToolPolicyEngineArgs {
45
42
  toolRegistry: ToolRegistry;
@@ -47,30 +44,65 @@ export interface ToolPolicyEngineArgs {
47
44
  customSources?: readonly PolicySource[];
48
45
  /** Stable context label used in provenance trails. Defaults to "tool-policy". */
49
46
  contextId?: string;
47
+ /**
48
+ * Whether the host may leave the assessment unbound without that being a
49
+ * misconfiguration; see {@link ResolvedEngineInputs.assessmentExpected}.
50
+ * Defaults to `false`.
51
+ */
52
+ assessmentOptional?: boolean;
50
53
  }
51
54
  export interface ToolPolicyChangeEvent {
52
- /** What changed in this update. */
53
- reason: "inputs" | "policy-source-added" | "policy-source-removed" | "pnp-enforcement" | "disposed";
55
+ /**
56
+ * What changed in this update. `"item-settings"` is a mounted item's
57
+ * settings changing: it can change which tools that item's own toolbar
58
+ * shows, and nothing else a toolbar renders.
59
+ */
60
+ reason: "inputs" | "item-settings" | "policy-source-added" | "policy-source-removed" | "pnp-enforcement" | "disposed";
54
61
  /** Snapshot of the engine's inputs after the change. */
55
62
  inputs: Readonly<ResolvedEngineInputs>;
56
63
  }
57
64
  export interface ResolvedEngineInputs {
58
65
  tools: CanonicalToolsConfig;
59
66
  assessment: AssessmentEntity | null;
60
- currentItemRef: AssessmentItemRef | null;
67
+ /**
68
+ * The mode a decision not scoped to an item applies. In auto-mode an
69
+ * item-scoped decision also turns on for its item's settings.
70
+ */
61
71
  pnpEnforcement: PnpEnforcementMode;
72
+ /** The host's override of auto-mode, or `null` in auto-mode. */
73
+ pnpEnforcementOverride: PnpEnforcementMode | null;
74
+ /**
75
+ * Whether an unbound assessment is a misconfiguration: always, unless the
76
+ * engine was built `assessmentOptional`, and then only while enforcement is
77
+ * overridden `"on"`.
78
+ */
79
+ assessmentExpected: boolean;
80
+ /**
81
+ * Conflicts in the inputs themselves, independent of any decision: a
82
+ * `tool-policy.unknownSupportId` for each id the assessment or a mounted
83
+ * item's settings name that no registered tool carries. Recomputed when the
84
+ * assessment, an item's settings or the registry's tools change.
85
+ */
86
+ diagnostics: readonly ToolPolicyDiagnostic[];
62
87
  }
63
88
  export type ToolPolicyChangeListener = (event: ToolPolicyChangeEvent) => void;
64
89
  export declare class ToolPolicyEngine {
65
90
  private toolRegistry;
91
+ private unsubscribeRegistry;
66
92
  private readonly contextId;
93
+ private readonly assessmentOptional;
67
94
  private pnpPolicySource;
68
95
  private readonly customSources;
69
96
  private readonly listeners;
70
97
  private tools;
71
98
  private assessment;
72
- private currentItemRef;
73
- private pnpEnforcement;
99
+ private pnpEnforcementOverride;
100
+ /**
101
+ * Mounted items' settings by canonical item id, newest registration last;
102
+ * see {@link registerItemSettings}.
103
+ */
104
+ private readonly itemSettings;
105
+ private inputDiagnostics;
74
106
  private disposed;
75
107
  constructor(args: ToolPolicyEngineArgs);
76
108
  /**
@@ -87,10 +119,38 @@ export declare class ToolPolicyEngine {
87
119
  * values even though the policy decision itself is identical.
88
120
  * Hosts that want timestamp-stable provenance should reuse a
89
121
  * cached `ToolPolicyDecision` rather than re-call `decide(...)`.
122
+ *
123
+ * An item's registered settings apply to the item's own toolbar: a request
124
+ * at item level whose scope is the item. Every other request — a section,
125
+ * assessment or passage toolbar — is shared by the items it sits beside, so
126
+ * it leaves every item's settings out and reports each tool on its toolbar
127
+ * that one restricts or requires as `tool-policy.itemSettingNotApplied`.
90
128
  */
91
129
  decide(request: ToolPolicyDecisionRequest): ToolPolicyDecision;
92
130
  /**
93
- * Resolve eligibility for one PNP/AfA feature id through the six-level
131
+ * Whether some surface is granted `featureId`: a decision with no item scope,
132
+ * or one scoped to a registered item. A provider serves every surface, so its
133
+ * failure denies the accommodation wherever one surface is granted it.
134
+ *
135
+ * `enforced` counts only scopes whose `pnpEnforcement` is on, as a toolbar
136
+ * tool's decisions do; a feature with no placement leaves it unset.
137
+ */
138
+ grantsFeatureAnywhere(featureId: string, options?: {
139
+ enforced?: boolean;
140
+ }): boolean;
141
+ /**
142
+ * File a mounted item's settings under its canonical id. They govern the
143
+ * decisions scoped to that item: its own toolbar, and a feature its content
144
+ * asks about with the item's scope. See {@link decide}.
145
+ *
146
+ * The same item mounted twice registers twice; the newest registration
147
+ * applies, and its cleanup hands the item back to the one before. Emits an
148
+ * `"item-settings"` change whenever the settings that apply to the item
149
+ * change.
150
+ */
151
+ registerItemSettings(itemId: string, settings: ItemSettings): () => void;
152
+ /**
153
+ * Resolve eligibility for one PNP/AfA feature id through the eight-level
94
154
  * precedence, independent of toolbar placement.
95
155
  *
96
156
  * For capabilities that render as their own surface rather than a toolbar
@@ -111,8 +171,11 @@ export declare class ToolPolicyEngine {
111
171
  * The decision reports whether an assessment was bound, which is the engine's
112
172
  * to answer rather than the policy source's — see
113
173
  * {@link FeaturePolicyDecision.assessmentBound}.
174
+ *
175
+ * `scope` is the surface asking. An item's scope brings in the item's
176
+ * registered settings, as {@link decide} does for the item's toolbar.
114
177
  */
115
- decideFeature(featureId: string): FeaturePolicyDecision;
178
+ decideFeature<K extends string>(featureId: K, scope?: ToolScope): FeaturePolicyDecision<ToolParametersFor<K>>;
116
179
  /**
117
180
  * The host gates that hold for a feature id, or `null` when none fires.
118
181
  *
@@ -133,17 +196,14 @@ export declare class ToolPolicyEngine {
133
196
  /**
134
197
  * Apply a partial input update.
135
198
  *
136
- * Each key is value-diffed via `Object.is` before storing, so callers
137
- * may safely re-push the same reference (e.g. on Svelte effect
138
- * re-runs caused by unrelated tracked reads): no-op patches do not
139
- * fire `onPolicyChange` listeners. This contract is relied on by
140
- * `PieAssessmentToolkit.svelte`'s prop-forwarding effect and by the
141
- * coordinator's `decideToolPolicy()` tests.
199
+ * A key that did not change does not fire `onPolicyChange` listeners.
200
+ * `tools` is diffed with `Object.is`. `assessment` is diffed structurally,
201
+ * because hosts rebuild it from their own state on every render; the latest
202
+ * reference is stored either way.
142
203
  *
143
- * `pnpEnforcement` is stored on its own field and always emits with
144
- * a distinct `"pnp-enforcement"` reason when no other key changed,
145
- * so PR 4's auto-on flip can target that reason without a separate
146
- * event channel.
204
+ * `pnpEnforcement` sets the override, `null` or `undefined` returning to
205
+ * auto-mode, and emits with a distinct `"pnp-enforcement"` reason when no
206
+ * other key changed.
147
207
  */
148
208
  updateInputs(patch: Partial<ToolPolicyEngineInputs>): void;
149
209
  /**
@@ -157,6 +217,30 @@ export declare class ToolPolicyEngine {
157
217
  getInputs(): Readonly<ResolvedEngineInputs>;
158
218
  dispose(): void;
159
219
  private snapshotInputs;
220
+ /** The override, else auto-mode over the assessment and `item`'s settings. */
221
+ private enforcementFor;
222
+ /** The settings that apply to `itemId`: its newest registration's. */
223
+ private itemSettingsFor;
224
+ private emitIfItemSettingsChanged;
225
+ /**
226
+ * Recompute {@link ResolvedEngineInputs.diagnostics} from the bound
227
+ * assessment, every mounted item's settings and the registry. Returns
228
+ * whether they changed.
229
+ */
230
+ private refreshInputDiagnostics;
231
+ /**
232
+ * Registering a tool into the bound registry, or removing one, can make a
233
+ * named id known or unknown, so it emits an `"inputs"` change when the input
234
+ * diagnostics move.
235
+ */
236
+ private watchRegistry;
237
+ /**
238
+ * The registered item an item scope names, by its canonical id. A scope
239
+ * of any other level names none.
240
+ */
241
+ private itemForScope;
242
+ /** The registered items whose settings their own toolbar enforces. */
243
+ private enforcedItems;
160
244
  private emit;
161
245
  private assertNotDisposed;
162
246
  }