@pie-players/pie-assessment-toolkit 0.3.73 → 0.3.75

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 (274) hide show
  1. package/README.md +469 -318
  2. package/dist/attempt/AssessmentSession.d.ts +1 -5
  3. package/dist/attempt/AssessmentSession.js +0 -29
  4. package/dist/attempt/TestSession.d.ts +1 -20
  5. package/dist/attempt/TestSession.js +8 -99
  6. package/dist/components/ItemScope.custom-element.d.ts +1 -0
  7. package/dist/components/ItemScope.custom-element.js +1 -0
  8. package/dist/components/ItemToolBar.custom-element.d.ts +1 -0
  9. package/dist/components/ItemToolBar.custom-element.js +1 -1
  10. package/dist/components/PieAssessmentToolkit.custom-element.d.ts +1 -0
  11. package/dist/components/PieAssessmentToolkit.custom-element.js +13 -13
  12. package/dist/components/SectionToolBar.custom-element.d.ts +1 -0
  13. package/dist/components/SectionToolBar.custom-element.js +1 -1
  14. package/dist/components/chunks/ItemToolBar-7tt7v2xp.js +4 -0
  15. package/dist/components/chunks/ItemToolBar-97hx60z4.js +2 -0
  16. package/dist/components/chunks/ItemToolBar-bxwyhr5p.js +2 -0
  17. package/dist/components/chunks/ItemToolBar-jx38w99s.js +2 -0
  18. package/dist/components/chunks/ItemToolBar-rd2bb4p6.js +40 -0
  19. package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
  20. package/dist/components/chunks/sre-engine-jd8cc08x.js +1 -0
  21. package/dist/components/item-scope-element.d.ts +2 -0
  22. package/dist/components/item-scope-element.js +2 -0
  23. package/dist/context/assessment-toolkit-context.d.ts +32 -6
  24. package/dist/index.d.ts +23 -48
  25. package/dist/index.js +12 -37
  26. package/dist/policy/core/PolicySource.d.ts +1 -1
  27. package/dist/policy/core/ToolPolicyEngine.d.ts +85 -34
  28. package/dist/policy/core/ToolPolicyEngine.js +148 -46
  29. package/dist/policy/core/compose-decision.d.ts +28 -7
  30. package/dist/policy/core/compose-decision.js +75 -54
  31. package/dist/policy/core/decision-types.d.ts +65 -34
  32. package/dist/policy/core/feature-decision.d.ts +16 -9
  33. package/dist/policy/core/feature-decision.js +14 -8
  34. package/dist/policy/core/pnp-policy-inputs.d.ts +24 -33
  35. package/dist/policy/core/pnp-policy-inputs.js +28 -56
  36. package/dist/policy/core/provenance.d.ts +9 -4
  37. package/dist/policy/core/provenance.js +1 -1
  38. package/dist/policy/engine.d.ts +7 -23
  39. package/dist/policy/engine.js +5 -20
  40. package/dist/policy/sources/PnpPolicySource.d.ts +44 -61
  41. package/dist/policy/sources/PnpPolicySource.js +117 -118
  42. package/dist/runtime/SectionControllerBinding.d.ts +279 -0
  43. package/dist/runtime/SectionControllerBinding.js +450 -0
  44. package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
  45. package/dist/runtime/SectionRuntimeEngine.js +30 -372
  46. package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
  47. package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
  48. package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
  49. package/dist/runtime/adapter/dom-event-bridge.js +17 -44
  50. package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -2
  51. package/dist/runtime/adapter/subscriber-fanout.js +1 -2
  52. package/dist/runtime/catalog-context.d.ts +19 -0
  53. package/dist/runtime/catalog-context.js +28 -0
  54. package/dist/runtime/composition-emit-scheduler.d.ts +9 -15
  55. package/dist/runtime/composition-emit-scheduler.js +9 -15
  56. package/dist/runtime/content-language.d.ts +32 -0
  57. package/dist/runtime/content-language.js +46 -0
  58. package/dist/runtime/content-region.d.ts +17 -0
  59. package/dist/runtime/content-region.js +29 -0
  60. package/dist/runtime/content-registration.d.ts +13 -0
  61. package/dist/runtime/content-registration.js +25 -0
  62. package/dist/runtime/core/SectionEngineCore.d.ts +2 -2
  63. package/dist/runtime/core/SectionEngineCore.js +2 -2
  64. package/dist/runtime/core/cohort.d.ts +1 -1
  65. package/dist/runtime/core/cohort.js +1 -1
  66. package/dist/runtime/core/engine-input.d.ts +18 -30
  67. package/dist/runtime/core/engine-input.js +11 -12
  68. package/dist/runtime/core/engine-output.d.ts +16 -40
  69. package/dist/runtime/core/engine-output.js +9 -21
  70. package/dist/runtime/core/engine-readiness.d.ts +5 -37
  71. package/dist/runtime/core/engine-readiness.js +8 -41
  72. package/dist/runtime/core/engine-resolver.d.ts +46 -74
  73. package/dist/runtime/core/engine-resolver.js +18 -43
  74. package/dist/runtime/core/engine-state.d.ts +28 -36
  75. package/dist/runtime/core/engine-state.js +18 -21
  76. package/dist/runtime/core/engine-transition.d.ts +14 -19
  77. package/dist/runtime/core/engine-transition.js +71 -51
  78. package/dist/runtime/engine.d.ts +16 -19
  79. package/dist/runtime/engine.js +12 -19
  80. package/dist/runtime/page-warnings.d.ts +13 -0
  81. package/dist/runtime/page-warnings.js +22 -0
  82. package/dist/runtime/policy-input-forwarding.d.ts +25 -0
  83. package/dist/runtime/policy-input-forwarding.js +25 -0
  84. package/dist/runtime/registration-events.d.ts +14 -0
  85. package/dist/runtime/runtime-event-claim.d.ts +8 -0
  86. package/dist/runtime/runtime-event-claim.js +15 -0
  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 +188 -0
  93. package/dist/runtime/tool-host-contract.d.ts +28 -10
  94. package/dist/runtime/tool-host-contract.js +31 -10
  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/ElementToolStateStore.d.ts +14 -10
  98. package/dist/services/ElementToolStateStore.js +37 -13
  99. package/dist/services/HighlightCoordinator.d.ts +22 -28
  100. package/dist/services/HighlightCoordinator.js +431 -327
  101. package/dist/services/RangeSerializer.d.ts +10 -1
  102. package/dist/services/RangeSerializer.js +87 -14
  103. package/dist/services/TTSService.d.ts +130 -69
  104. package/dist/services/TTSService.js +713 -570
  105. package/dist/services/ToolCoordinator.d.ts +43 -66
  106. package/dist/services/ToolCoordinator.js +164 -208
  107. package/dist/services/ToolRegistry.d.ts +78 -54
  108. package/dist/services/ToolRegistry.js +107 -105
  109. package/dist/services/ToolkitCoordinator.d.ts +261 -175
  110. package/dist/services/ToolkitCoordinator.js +667 -433
  111. package/dist/services/audio-handoff.d.ts +6 -7
  112. package/dist/services/audio-handoff.js +20 -14
  113. package/dist/services/catalog-owner.d.ts +11 -1
  114. package/dist/services/catalog-owner.js +25 -0
  115. package/dist/services/create-tools-config.d.ts +2 -2
  116. package/dist/services/framework-error-bus.d.ts +3 -6
  117. package/dist/services/framework-error-bus.js +3 -6
  118. package/dist/services/framework-error.d.ts +30 -8
  119. package/dist/services/framework-error.js +9 -7
  120. package/dist/services/interfaces.d.ts +158 -129
  121. package/dist/services/section-controller-types.d.ts +15 -0
  122. package/dist/services/section-session-assignment.d.ts +21 -0
  123. package/dist/services/section-session-assignment.js +82 -0
  124. package/dist/services/spoken-audio-cards.d.ts +0 -2
  125. package/dist/services/spoken-audio-cards.js +1 -3
  126. package/dist/services/tool-config-defaults.d.ts +3 -3
  127. package/dist/services/tool-config-defaults.js +3 -3
  128. package/dist/services/tool-config-validation.d.ts +14 -4
  129. package/dist/services/tool-config-validation.js +63 -71
  130. package/dist/services/tool-context.d.ts +0 -8
  131. package/dist/services/tool-context.js +29 -25
  132. package/dist/services/tool-icons.d.ts +4 -3
  133. package/dist/services/tool-icons.js +4 -3
  134. package/dist/services/tool-instance-id.d.ts +0 -1
  135. package/dist/services/tool-instance-id.js +0 -6
  136. package/dist/services/tool-providers/TTSToolProvider.d.ts +41 -80
  137. package/dist/services/tool-providers/TTSToolProvider.js +81 -40
  138. package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -4
  139. package/dist/services/tool-providers/ToolProviderRegistry.d.ts +32 -28
  140. package/dist/services/tool-providers/ToolProviderRegistry.js +121 -107
  141. package/dist/services/tool-providers/index.d.ts +0 -9
  142. package/dist/services/tool-providers/index.js +2 -4
  143. package/dist/services/tool-request.d.ts +27 -12
  144. package/dist/services/tool-request.js +24 -14
  145. package/dist/services/toolbar-decided-tools.d.ts +15 -0
  146. package/dist/services/toolbar-decided-tools.js +28 -0
  147. package/dist/services/tools-config-normalizer.d.ts +37 -23
  148. package/dist/services/tools-config-normalizer.js +2 -10
  149. package/dist/services/tts/browser-provider.d.ts +38 -2
  150. package/dist/services/tts/browser-provider.js +276 -140
  151. package/dist/services/tts/catalog-span-alignment.d.ts +2 -17
  152. package/dist/services/tts/catalog-span-alignment.js +17 -142
  153. package/dist/services/tts/flat-tree.d.ts +71 -0
  154. package/dist/services/tts/flat-tree.js +269 -0
  155. package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
  156. package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
  157. package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
  158. package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
  159. package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
  160. package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
  161. package/dist/services/tts/generated-speech/types.d.ts +0 -12
  162. package/dist/services/tts/highlight-pipeline/boundary-normalizer.js +12 -62
  163. package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +38 -5
  164. package/dist/services/tts/highlight-pipeline/normalize-speech-chunks.js +3 -6
  165. package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
  166. package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
  167. package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
  168. package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
  169. package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
  170. package/dist/services/tts/math-alignment/index.d.ts +0 -5
  171. package/dist/services/tts/math-alignment/index.js +5 -25
  172. package/dist/services/tts/math-alignment/speech-tokenizer.d.ts +9 -1
  173. package/dist/services/tts/math-alignment/speech-tokenizer.js +38 -36
  174. package/dist/services/tts/math-alignment/types.d.ts +4 -2
  175. package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
  176. package/dist/services/tts/math-aware-text-processing.js +74 -18
  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 +16 -1
  180. package/dist/services/tts/math-speech.js +55 -19
  181. package/dist/services/tts/provider-options.d.ts +41 -0
  182. package/dist/services/tts/provider-options.js +1 -0
  183. package/dist/services/tts/sre-engine.d.ts +7 -0
  184. package/dist/services/tts/sre-engine.js +11 -0
  185. package/dist/services/tts/sre-locales.d.ts +14 -0
  186. package/dist/services/tts/sre-locales.js +57 -0
  187. package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
  188. package/dist/services/tts/ssml/spoken-text.js +29 -0
  189. package/dist/services/tts/start-failure.d.ts +11 -0
  190. package/dist/services/tts/start-failure.js +19 -0
  191. package/dist/services/tts/text-processing.d.ts +9 -1
  192. package/dist/services/tts/text-processing.js +46 -34
  193. package/dist/services/tts/text-segmentation.d.ts +7 -0
  194. package/dist/services/tts/text-segmentation.js +47 -0
  195. package/dist/services/tts-runtime-config.d.ts +44 -18
  196. package/dist/services/tts-runtime-config.js +22 -93
  197. package/dist/tools/content-capability-resolution.d.ts +7 -9
  198. package/dist/tools/content-capability-resolution.js +8 -45
  199. package/dist/tools/registration.d.ts +58 -0
  200. package/dist/tools/registration.js +54 -0
  201. package/dist/tools/registrations/toolbar-registration-helpers.js +2 -2
  202. package/dist/tools/tool-surface-host.d.ts +6 -10
  203. package/dist/tools/tool-surface-host.js +44 -42
  204. package/dist/tools/tool-tag-map.d.ts +5 -15
  205. package/dist/tools/tool-tag-map.js +6 -20
  206. package/dist/utils/structural-equality.d.ts +11 -0
  207. package/dist/utils/structural-equality.js +47 -0
  208. package/package.json +24 -59
  209. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
  210. package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
  211. package/dist/components/chunks/ItemToolBar-byq80z42.js +0 -40
  212. package/dist/components/chunks/ItemToolBar-d36g3aw4.js +0 -49
  213. package/dist/context/runtime-context-consumer.d.ts +0 -13
  214. package/dist/context/runtime-context-consumer.js +0 -51
  215. package/dist/item-loader.d.ts +0 -44
  216. package/dist/item-loader.js +0 -61
  217. package/dist/policy/core/engine-context.d.ts +0 -29
  218. package/dist/policy/core/engine-context.js +0 -27
  219. package/dist/policy/core/policy-source-tag.d.ts +0 -31
  220. package/dist/policy/core/policy-source-tag.js +0 -28
  221. package/dist/policy/internal.d.ts +0 -25
  222. package/dist/policy/internal.js +0 -25
  223. package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
  224. package/dist/runtime/adapter/coordinator-bridge.js +0 -126
  225. package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
  226. package/dist/runtime/adapter/framework-error-bridge.js +0 -46
  227. package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
  228. package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
  229. package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
  230. package/dist/runtime/core/engine-stage-derivation.js +0 -29
  231. package/dist/runtime/engine-context.d.ts +0 -39
  232. package/dist/runtime/engine-context.js +0 -31
  233. package/dist/runtime/internal.d.ts +0 -43
  234. package/dist/runtime/internal.js +0 -45
  235. package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -80
  236. package/dist/runtime/section-runtime-engine-host-context.js +0 -95
  237. package/dist/runtime/stage-emit-gate.d.ts +0 -92
  238. package/dist/runtime/stage-emit-gate.js +0 -82
  239. package/dist/services/I18nService.d.ts +0 -47
  240. package/dist/services/I18nService.js +0 -84
  241. package/dist/services/ThemeProvider.d.ts +0 -95
  242. package/dist/services/ThemeProvider.js +0 -334
  243. package/dist/services/ToolConfigResolver.d.ts +0 -161
  244. package/dist/services/ToolConfigResolver.js +0 -229
  245. package/dist/services/catalog-media.d.ts +0 -56
  246. package/dist/services/catalog-media.js +0 -190
  247. package/dist/services/createDefaultToolRegistry.d.ts +0 -53
  248. package/dist/services/createDefaultToolRegistry.js +0 -45
  249. package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
  250. package/dist/services/defaultPersonalNeedsProfile.js +0 -26
  251. package/dist/services/pnp-standard-features.d.ts +0 -238
  252. package/dist/services/pnp-standard-features.js +0 -338
  253. package/dist/services/tool-providers/CortexToolProvider.d.ts +0 -13
  254. package/dist/services/tool-providers/CortexToolProvider.js +0 -32
  255. package/dist/services/tool-providers/DesmosToolProvider.d.ts +0 -14
  256. package/dist/services/tool-providers/DesmosToolProvider.js +0 -32
  257. package/dist/services/tool-providers/GeoGebraToolProvider.d.ts +0 -16
  258. package/dist/services/tool-providers/GeoGebraToolProvider.js +0 -32
  259. package/dist/services/tool-providers/LazyCalculatorToolProvider.d.ts +0 -35
  260. package/dist/services/tool-providers/LazyCalculatorToolProvider.js +0 -95
  261. package/dist/services/tts/visual-line-ranges.d.ts +0 -18
  262. package/dist/services/tts/visual-line-ranges.js +0 -226
  263. package/dist/tools/client.d.ts +0 -12
  264. package/dist/tools/client.js +0 -14
  265. package/dist/tools/index.d.ts +0 -8
  266. package/dist/tools/index.js +0 -10
  267. package/dist/tools/internal.d.ts +0 -43
  268. package/dist/tools/internal.js +0 -41
  269. package/dist/tools/response-discovery.d.ts +0 -61
  270. package/dist/tools/response-discovery.js +0 -113
  271. package/dist/tools/types.d.ts +0 -337
  272. package/dist/tools/types.js +0 -12
  273. package/dist/tools/variant-resolver.d.ts +0 -41
  274. package/dist/tools/variant-resolver.js +0 -207
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Section runtime engine — pure core (M7 — Variant C, layered).
2
+ * Section runtime engine — pure core.
3
3
  *
4
4
  * `SectionEngineCore` is a thin object oriented wrapper over the pure
5
5
  * `transition()` function. It owns the current `SectionEngineState`,
6
6
  * applies inputs serially, and fans out the resulting
7
7
  * `SectionEngineOutput[]` to subscribers. There is no DOM, Svelte,
8
8
  * coordinator, or timing dependency in this module — all I/O lives in
9
- * the adapter layer (PR 2).
9
+ * the adapter layer.
10
10
  *
11
11
  * Lifetime model:
12
12
  * - One instance per cohort logical lifetime. Cohort changes happen
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Section runtime engine — pure core (M7 — Variant C, layered).
2
+ * Section runtime engine — pure core.
3
3
  *
4
4
  * `SectionEngineCore` is a thin object oriented wrapper over the pure
5
5
  * `transition()` function. It owns the current `SectionEngineState`,
6
6
  * applies inputs serially, and fans out the resulting
7
7
  * `SectionEngineOutput[]` to subscribers. There is no DOM, Svelte,
8
8
  * coordinator, or timing dependency in this module — all I/O lives in
9
- * the adapter layer (PR 2).
9
+ * the adapter layer.
10
10
  *
11
11
  * Lifetime model:
12
12
  * - One instance per cohort logical lifetime. Cohort changes happen
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Cohort identity for the section runtime engine (M7).
2
+ * Cohort identity for the section runtime engine.
3
3
  *
4
4
  * One cohort is the tuple `(sectionId, attemptId)` for the section the
5
5
  * host is currently rendering. Stage progression, readiness latches, and
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Cohort identity for the section runtime engine (M7).
2
+ * Cohort identity for the section runtime engine.
3
3
  *
4
4
  * One cohort is the tuple `(sectionId, attemptId)` for the section the
5
5
  * host is currently rendering. Stage progression, readiness latches, and
@@ -1,24 +1,22 @@
1
1
  /**
2
- * Section runtime engine inputs (M7 — Variant C, layered core).
2
+ * Section runtime engine inputs.
3
3
  *
4
- * Inputs are the discriminated union of events the adapter (PR 2) feeds
5
- * into the pure transition function (`engine-transition.ts`). The shape
6
- * is closed: every field is plain data so the transition can be tested
7
- * without any DOM, Svelte, or coordinator wiring.
4
+ * Inputs are the closed union of events the adapter feeds into the pure
5
+ * transition function (`engine-transition.ts`). Every field is plain data, so
6
+ * the transition is testable without DOM, Svelte, or coordinator wiring.
8
7
  *
9
8
  * Adapter→core boundary contract:
10
- * - The adapter never mutates engine state directly. It always
11
- * constructs an input and calls `core.dispatch(input)`.
12
- * - Inputs are total: an unhandled `kind` is a programming error
13
- * (the transition uses `assertNever` exhaustiveness).
14
- * - Inputs carry only data, never live host references that would
15
- * pin lifetime. Coordinator and controller handles live in the
16
- * adapter; the core only sees readiness signals derived from them.
9
+ * - The adapter never mutates engine state directly. It constructs an input
10
+ * and calls `core.dispatch(input)`.
11
+ * - The transition switch is exhaustive over `kind`: a new input kind that
12
+ * it does not handle fails to type-check.
13
+ * - Inputs carry no live host references. Coordinator and controller handles
14
+ * live in the adapter; the core sees only readiness signals derived from
15
+ * them.
17
16
  */
18
17
  import type { CohortKey } from "./cohort.js";
19
18
  import type { EffectiveRuntime, RuntimeInputs } from "./engine-resolver.js";
20
19
  import type { EngineReadinessSignals } from "./engine-readiness.js";
21
- import type { FrameworkErrorModel } from "../../services/framework-error.js";
22
20
  /**
23
21
  * `initialize` is the first transition out of `idle`. It carries the
24
22
  * cohort key and the resolved runtime/tools snapshot for the cohort.
@@ -60,7 +58,8 @@ export type EngineInputCohortChange = {
60
58
  * the controller for the current cohort. Advances the phase from
61
59
  * `booting-section` → `engine-ready` (assuming `composed` is already
62
60
  * implied by `phase >= booting-section`, which the FSM treats as
63
- * monotonic).
61
+ * monotonic), and on to `interactive` when the last readiness snapshot
62
+ * already satisfies it.
64
63
  */
65
64
  export type EngineInputSectionControllerResolved = {
66
65
  kind: "section-controller-resolved";
@@ -68,7 +67,8 @@ export type EngineInputSectionControllerResolved = {
68
67
  /**
69
68
  * `update-readiness-signals` carries the latest readiness snapshot
70
69
  * from the host. The transition uses it to gate the move into
71
- * `interactive` and to decide whether to emit `loading-complete`.
70
+ * `interactive`, to end the chain as `failed` when `runtimeError` is set
71
+ * before `interactive`, and to decide whether to emit `loading-complete`.
72
72
  *
73
73
  * The full signal set is sent every time so the transition does not
74
74
  * have to reason about partial overlays.
@@ -76,7 +76,6 @@ export type EngineInputSectionControllerResolved = {
76
76
  export type EngineInputUpdateReadinessSignals = {
77
77
  kind: "update-readiness-signals";
78
78
  signals: EngineReadinessSignals;
79
- loadedCount: number;
80
79
  itemCount: number;
81
80
  /**
82
81
  * Strict-mode gate. When `"strict"`, `interactive` only fires
@@ -86,26 +85,15 @@ export type EngineInputUpdateReadinessSignals = {
86
85
  */
87
86
  mode: "progressive" | "strict";
88
87
  };
89
- /**
90
- * `framework-error` is sent for every framework-error report (M3
91
- * canonical channel). The transition records the latest error in
92
- * state and emits a `framework-error` output so the adapter can fan
93
- * out to subscribers and the DOM event.
94
- */
95
- export type EngineInputFrameworkError = {
96
- kind: "framework-error";
97
- error: FrameworkErrorModel;
98
- };
99
88
  /**
100
89
  * `dispose` tears the engine down. Emits `disposed` for the current
101
- * cohort (if any) and moves to the terminal `disposed` phase. After
102
- * dispose the engine accepts no further inputs (the transition logs
103
- * a warning and is a no-op).
90
+ * cohort (if any) and moves to the terminal `disposed` phase. Every input
91
+ * after dispose is a no-op.
104
92
  */
105
93
  export type EngineInputDispose = {
106
94
  kind: "dispose";
107
95
  };
108
- export type SectionEngineInput = EngineInputInitialize | EngineInputUpdateRuntime | EngineInputCohortChange | EngineInputSectionControllerResolved | EngineInputUpdateReadinessSignals | EngineInputFrameworkError | EngineInputDispose;
96
+ export type SectionEngineInput = EngineInputInitialize | EngineInputUpdateRuntime | EngineInputCohortChange | EngineInputSectionControllerResolved | EngineInputUpdateReadinessSignals | EngineInputDispose;
109
97
  /**
110
98
  * Convenience re-export so the adapter can import `RuntimeInputs`
111
99
  * from a single place when it constructs `initialize` inputs.
@@ -1,18 +1,17 @@
1
1
  /**
2
- * Section runtime engine inputs (M7 — Variant C, layered core).
2
+ * Section runtime engine inputs.
3
3
  *
4
- * Inputs are the discriminated union of events the adapter (PR 2) feeds
5
- * into the pure transition function (`engine-transition.ts`). The shape
6
- * is closed: every field is plain data so the transition can be tested
7
- * without any DOM, Svelte, or coordinator wiring.
4
+ * Inputs are the closed union of events the adapter feeds into the pure
5
+ * transition function (`engine-transition.ts`). Every field is plain data, so
6
+ * the transition is testable without DOM, Svelte, or coordinator wiring.
8
7
  *
9
8
  * Adapter→core boundary contract:
10
- * - The adapter never mutates engine state directly. It always
11
- * constructs an input and calls `core.dispatch(input)`.
12
- * - Inputs are total: an unhandled `kind` is a programming error
13
- * (the transition uses `assertNever` exhaustiveness).
14
- * - Inputs carry only data, never live host references that would
15
- * pin lifetime. Coordinator and controller handles live in the
16
- * adapter; the core only sees readiness signals derived from them.
9
+ * - The adapter never mutates engine state directly. It constructs an input
10
+ * and calls `core.dispatch(input)`.
11
+ * - The transition switch is exhaustive over `kind`: a new input kind that
12
+ * it does not handle fails to type-check.
13
+ * - Inputs carry no live host references. Coordinator and controller handles
14
+ * live in the adapter; the core sees only readiness signals derived from
15
+ * them.
17
16
  */
18
17
  export {};
@@ -1,36 +1,22 @@
1
1
  /**
2
- * Section runtime engine outputs (M7 — Variant C, layered core).
2
+ * Section runtime engine outputs.
3
3
  *
4
- * Outputs are the closed discriminated union of effects the transition
5
- * function returns. The adapter (PR 2) takes the output array, walks
6
- * it in order, and dispatches each one to the right bridge (DOM
7
- * events, framework-error bus, subscriber fan-out).
4
+ * Outputs are the closed union of effects the transition function returns. The
5
+ * adapter walks each batch in order and hands it to the DOM-event bridge and the
6
+ * subscriber fan-out. Outputs carry only plain data, so the transition table is
7
+ * testable without DOM or coordinator wiring.
8
8
  *
9
- * Outputs carry only plain data so the transition table can be tested
10
- * exhaustively without any DOM or coordinator wiring.
11
- *
12
- * Adjustment A2 from the M7 implementation plan: `loading-complete`
13
- * is an output, **not** an FSM phase. The transition emits it from
14
- * the `interactive` phase when the readiness signals indicate every
15
- * item has finished loading. This mirrors today's
16
- * `pie-loading-complete` DOM event semantics.
17
- *
18
- * Readiness alias output kinds (`readiness-change`,
19
- * `interaction-ready`, `ready`) were removed in the broad
20
- * architecture review compat sweep along with their DOM-event bridge
21
- * event bridge. Stage and readiness changes now flow
22
- * through `stage-change` (with `EngineReadinessDetail` available via
23
- * `SectionEngineCore.getState()` / kernel `selectReadiness()`); the
24
- * "all items loaded" signal flows through `loading-complete` only.
9
+ * Framework errors are not an output. The toolkit that owns the coordinator
10
+ * publishes each one once, as its `framework-error` event and `onFrameworkError`
11
+ * hook; the engine sees an error only through the readiness signals, and a
12
+ * fatal one before `interactive` ends the cohort's stage chain as `failed`.
25
13
  */
26
14
  import type { Stage, StageStatus } from "@pie-players/pie-players-shared/pie";
27
15
  import type { CohortKey } from "./cohort.js";
28
- import type { FrameworkErrorModel } from "../../services/framework-error.js";
29
16
  /**
30
- * Stage transition. The adapter dispatches a `pie-stage-change` DOM
31
- * event with the canonical detail and forwards to subscribers /
32
- * coordinator. The status indicates whether the stage was entered,
33
- * skipped, or recorded as failed.
17
+ * Stage transition. The adapter dispatches it as `pie-stage-change` with the
18
+ * canonical detail. The status says whether the stage was entered, skipped, or
19
+ * recorded as failed.
34
20
  */
35
21
  export type EngineOutputStageChange = {
36
22
  kind: "stage-change";
@@ -39,23 +25,13 @@ export type EngineOutputStageChange = {
39
25
  cohort: CohortKey | null;
40
26
  };
41
27
  /**
42
- * Canonical `pie-loading-complete` emit (M6 D1). One-shot per cohort.
43
- * Fires from the `interactive` phase when loaded == items count and
44
- * the readiness signals satisfy `allLoadingComplete`.
28
+ * Canonical `pie-loading-complete`. One-shot per cohort, emitted when the
29
+ * readiness signals satisfy `allLoadingComplete`, so every one of `itemCount`
30
+ * items has loaded.
45
31
  */
46
32
  export type EngineOutputLoadingComplete = {
47
33
  kind: "loading-complete";
48
34
  cohort: CohortKey;
49
35
  itemCount: number;
50
- loadedCount: number;
51
- };
52
- /**
53
- * Framework error fan-out. Mirrors the M3 `framework-error` DOM event
54
- * and the `subscribeFrameworkErrors` listener channel. Emitted on
55
- * every `framework-error` input.
56
- */
57
- export type EngineOutputFrameworkError = {
58
- kind: "framework-error";
59
- error: FrameworkErrorModel;
60
36
  };
61
- export type SectionEngineOutput = EngineOutputStageChange | EngineOutputLoadingComplete | EngineOutputFrameworkError;
37
+ export type SectionEngineOutput = EngineOutputStageChange | EngineOutputLoadingComplete;
@@ -1,26 +1,14 @@
1
1
  /**
2
- * Section runtime engine outputs (M7 — Variant C, layered core).
2
+ * Section runtime engine outputs.
3
3
  *
4
- * Outputs are the closed discriminated union of effects the transition
5
- * function returns. The adapter (PR 2) takes the output array, walks
6
- * it in order, and dispatches each one to the right bridge (DOM
7
- * events, framework-error bus, subscriber fan-out).
4
+ * Outputs are the closed union of effects the transition function returns. The
5
+ * adapter walks each batch in order and hands it to the DOM-event bridge and the
6
+ * subscriber fan-out. Outputs carry only plain data, so the transition table is
7
+ * testable without DOM or coordinator wiring.
8
8
  *
9
- * Outputs carry only plain data so the transition table can be tested
10
- * exhaustively without any DOM or coordinator wiring.
11
- *
12
- * Adjustment A2 from the M7 implementation plan: `loading-complete`
13
- * is an output, **not** an FSM phase. The transition emits it from
14
- * the `interactive` phase when the readiness signals indicate every
15
- * item has finished loading. This mirrors today's
16
- * `pie-loading-complete` DOM event semantics.
17
- *
18
- * Readiness alias output kinds (`readiness-change`,
19
- * `interaction-ready`, `ready`) were removed in the broad
20
- * architecture review compat sweep along with their DOM-event bridge
21
- * event bridge. Stage and readiness changes now flow
22
- * through `stage-change` (with `EngineReadinessDetail` available via
23
- * `SectionEngineCore.getState()` / kernel `selectReadiness()`); the
24
- * "all items loaded" signal flows through `loading-complete` only.
9
+ * Framework errors are not an output. The toolkit that owns the coordinator
10
+ * publishes each one once, as its `framework-error` event and `onFrameworkError`
11
+ * hook; the engine sees an error only through the readiness signals, and a
12
+ * fatal one before `interactive` ends the cohort's stage chain as `failed`.
25
13
  */
26
14
  export {};
@@ -1,48 +1,16 @@
1
1
  /**
2
- * Readiness derivation for the section runtime engine (M7).
3
- *
4
- * Canonical home of `createReadinessDetail` and `resolveReadinessPhase`.
5
- * As of M7 PR 7 the previous duplicates in
6
- * `packages/section-player/src/components/shared/section-player-readiness.ts`
7
- * have been deleted; section-player now consumes these helpers via
8
- * `@pie-players/pie-assessment-toolkit/runtime/internal`.
9
- *
10
- * Type duplication note: the public DOM-event detail aliases
11
- * (`SectionPlayerReadinessChangeDetail` /
12
- * `SectionPlayerReadinessPhase`) still live in section-player's
13
- * `contracts/public-events.ts` because that file is part of section-
14
- * player's published custom-element contract. The toolkit core defines
15
- * `EngineReadinessPhase` independently so it has zero section-player
16
- * imports. The two definitions must stay structurally identical;
17
- * that invariant is covered by the readiness assertions in this
18
- * package's tests, which mirror the section-player suite.
2
+ * Readiness gating for the section runtime engine: which of the host's
3
+ * readiness signals open `interactive` and `loading-complete` under the
4
+ * section's readiness mode.
19
5
  */
20
- /**
21
- * Coarse readiness phase label, derived from the four readiness
22
- * signals. Surfaced via the kernel's `selectReadiness()` /
23
- * `getSnapshot().readiness` selectors; M6 stages own the stage-level
24
- * transitions on `pie-stage-change` and use this phase as a
25
- * convenience label only. The `readiness-change` DOM
26
- * event that used to surface this directly was removed in the broad
27
- * architecture review compat sweep alongside its
28
- * event bridge.
29
- */
30
- export type EngineReadinessPhase = "bootstrapping" | "interaction-ready" | "loading" | "ready" | "error";
31
6
  export type EngineReadinessSignals = {
32
7
  sectionReady: boolean;
33
8
  interactionReady: boolean;
34
9
  allLoadingComplete: boolean;
35
10
  runtimeError: boolean;
36
11
  };
37
- export type EngineReadinessDetail = {
38
- phase: EngineReadinessPhase;
12
+ export type EngineReadinessGates = {
39
13
  interactionReady: boolean;
40
14
  allLoadingComplete: boolean;
41
- reason?: string;
42
15
  };
43
- export declare function resolveReadinessPhase(signals: EngineReadinessSignals): EngineReadinessPhase;
44
- export declare function createReadinessDetail(args: {
45
- mode: "progressive" | "strict";
46
- signals: EngineReadinessSignals;
47
- reason?: string;
48
- }): EngineReadinessDetail;
16
+ export declare function resolveReadinessGates(mode: "progressive" | "strict", signals: EngineReadinessSignals): EngineReadinessGates;
@@ -1,46 +1,13 @@
1
1
  /**
2
- * Readiness derivation for the section runtime engine (M7).
3
- *
4
- * Canonical home of `createReadinessDetail` and `resolveReadinessPhase`.
5
- * As of M7 PR 7 the previous duplicates in
6
- * `packages/section-player/src/components/shared/section-player-readiness.ts`
7
- * have been deleted; section-player now consumes these helpers via
8
- * `@pie-players/pie-assessment-toolkit/runtime/internal`.
9
- *
10
- * Type duplication note: the public DOM-event detail aliases
11
- * (`SectionPlayerReadinessChangeDetail` /
12
- * `SectionPlayerReadinessPhase`) still live in section-player's
13
- * `contracts/public-events.ts` because that file is part of section-
14
- * player's published custom-element contract. The toolkit core defines
15
- * `EngineReadinessPhase` independently so it has zero section-player
16
- * imports. The two definitions must stay structurally identical;
17
- * that invariant is covered by the readiness assertions in this
18
- * package's tests, which mirror the section-player suite.
2
+ * Readiness gating for the section runtime engine: which of the host's
3
+ * readiness signals open `interactive` and `loading-complete` under the
4
+ * section's readiness mode.
19
5
  */
20
- export function resolveReadinessPhase(signals) {
21
- if (signals.runtimeError)
22
- return "error";
23
- if (signals.allLoadingComplete)
24
- return "ready";
25
- if (signals.interactionReady)
26
- return "interaction-ready";
27
- if (signals.sectionReady)
28
- return "loading";
29
- return "bootstrapping";
30
- }
31
- export function createReadinessDetail(args) {
32
- // Final ready must always be gated by section lifecycle and complete loading.
33
- const finalReady = args.signals.sectionReady && args.signals.allLoadingComplete;
34
- const interactionReady = args.mode === "strict" ? finalReady : args.signals.interactionReady;
35
- const phase = resolveReadinessPhase({
36
- ...args.signals,
37
- allLoadingComplete: finalReady,
38
- interactionReady,
39
- });
6
+ export function resolveReadinessGates(mode, signals) {
7
+ // Final ready is always gated by the section lifecycle and complete loading.
8
+ const allLoadingComplete = signals.sectionReady && signals.allLoadingComplete;
40
9
  return {
41
- phase,
42
- interactionReady,
43
- allLoadingComplete: finalReady,
44
- reason: args.reason,
10
+ interactionReady: mode === "strict" ? allLoadingComplete : signals.interactionReady,
11
+ allLoadingComplete,
45
12
  };
46
13
  }
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Section runtime engine resolver (M7).
2
+ * Section runtime engine resolver.
3
3
  *
4
4
  * Canonical home of `resolveRuntime`, `resolveToolsConfig`, and their
5
- * supporting helpers/types. As of M7 PR 7 the previous duplicates in
6
- * `packages/section-player/src/components/shared/section-player-runtime.ts`
7
- * have been deleted; section-player now consumes these helpers via
8
- * `@pie-players/pie-assessment-toolkit/runtime/internal`.
5
+ * supporting helpers/types; section-player consumes them through
6
+ * `@pie-players/pie-assessment-toolkit/runtime/engine`.
9
7
  *
10
8
  * What is NOT absorbed in this module:
11
9
  * - `resolvePlayerRuntime` stays in section-player because it depends on
@@ -18,22 +16,26 @@
18
16
  * `packages/section-player/src/components/shared/section-player-host-runtime.ts`)
19
17
  * hands its local implementation in.
20
18
  *
21
- * Runtime-owned configuration flows through `runtime.<key>`. Layout-only
22
- * inputs stay on the section-player host elements.
19
+ * Each input has one tier. `assessmentId`, the tools and player config and the
20
+ * `on*` callbacks arrive on `runtime`. The primitive inputs (`nds-icons`,
21
+ * `locale`, `tool-config-strictness`) are element attributes; the resolver takes
22
+ * `toolConfigStrictness` beside `runtime`.
23
23
  */
24
24
  import type { LoaderConfig } from "@pie-players/pie-players-shared/loader-config";
25
25
  import type { LoadingCompleteDetail, StageChangeDetail } from "@pie-players/pie-players-shared/pie";
26
26
  import type { FrameworkErrorModel } from "../../services/framework-error.js";
27
27
  import type { ToolConfigStrictness } from "../../services/tool-config-validation.js";
28
- export declare const DEFAULT_ASSESSMENT_ID = "section-demo-direct";
29
28
  export declare const DEFAULT_PLAYER_TYPE = "iife";
30
- export declare const DEFAULT_LAZY_INIT = true;
29
+ export declare const DEFAULT_LAZY_INIT = false;
31
30
  export declare const DEFAULT_ISOLATION = "inherit";
32
31
  export declare const DEFAULT_ENV: Record<string, unknown>;
33
32
  export type PlayerOverrides = {
33
+ /** The host has already loaded the item bundles; the player loads none. */
34
+ hosted?: boolean;
34
35
  loaderConfig?: LoaderConfig;
35
36
  loaderOptions?: Record<string, unknown>;
36
- [key: string]: unknown;
37
+ /** The item player's `backend` config, passed through unread. */
38
+ backend?: Record<string, unknown> | null;
37
39
  };
38
40
  export type FrameworkErrorHandler = (model: FrameworkErrorModel) => void;
39
41
  export type StageChangeHandler = (detail: StageChangeDetail) => void;
@@ -61,48 +63,34 @@ export type RuntimeConfig = {
61
63
  isolation?: string;
62
64
  env?: Record<string, unknown>;
63
65
  /**
64
- * Presentation flag: opt-in to the vendored `<nds-icon-button>` for the
65
- * toolbar tool buttons, the calculator shell controls, inline-TTS
66
- * play/pause, and the section scroll-hint. NDS icons render only when
67
- * this is explicitly `true`; unset/`false` keeps the plain `<button>`
68
- * markup (the default). Purely visual — no engine effect.
69
- */
70
- ndsIcons?: boolean;
71
- /**
72
- * Interface locale: a BCP-47 tag naming the language the player renders its own
73
- * UI in. Purely presentational — no engine effect.
74
- *
75
- * Distinct from content language, which describes the authored item and
76
- * travels on `env`. QTI 3's implementation guide states the independence
77
- * directly: a candidate may choose an interface language which may or may not
78
- * also be the language of the content.
66
+ * Content language: a BCP-47 tag naming the language the authored content is
67
+ * written in, which read-aloud speaks it in and catalog lookups select
68
+ * alternates by. A `lang` in the content's markup wins over it. Purely
69
+ * presentational — no engine effect.
79
70
  *
80
- * Unset renders `en-US`. POSIX (`nl_NL`) and bare (`nl`) forms both resolve.
71
+ * Unset reads as `en-US` wherever the markup names no language.
81
72
  */
82
- locale?: string;
83
- toolConfigStrictness?: ToolConfigStrictness;
73
+ contentLanguage?: string;
84
74
  onFrameworkError?: FrameworkErrorHandler;
75
+ /** Called with each `pie-stage-change` detail. */
85
76
  onStageChange?: StageChangeHandler;
77
+ /** Called with each `pie-loading-complete` detail. */
86
78
  onLoadingComplete?: LoadingCompleteHandler;
87
79
  };
88
80
  export type RuntimeInputs = {
89
- assessmentId?: string;
90
- toolConfigStrictness?: ToolConfigStrictness;
91
- onFrameworkError?: FrameworkErrorHandler;
92
- onStageChange?: StageChangeHandler;
93
- onLoadingComplete?: LoadingCompleteHandler;
94
81
  runtime: RuntimeConfig | null;
82
+ toolConfigStrictness?: ToolConfigStrictness;
95
83
  };
96
84
  /**
97
- * Resolve the canonical `onFrameworkError` handler from the two-tier
98
- * surface. Precedence (highest first): `runtime.onFrameworkError`,
99
- * then top-level `onFrameworkError`. Layout CEs and the kernel call
100
- * this so every entry point converges on the same handler.
85
+ * The id a section runs under: the host's `section-id`, else the section's own
86
+ * `identifier`, else one named after the assessment. The toolkit keys the
87
+ * section's controller by it, and the layout kernel its stage cohort.
101
88
  */
102
- export declare function resolveOnFrameworkError(args: {
103
- runtime: RuntimeConfig | null;
104
- onFrameworkError?: FrameworkErrorHandler;
105
- }): FrameworkErrorHandler | undefined;
89
+ export declare function resolveSectionId(args: {
90
+ sectionId?: string | null;
91
+ section?: unknown;
92
+ assessmentId?: string | null;
93
+ }): string;
106
94
  export declare function resolveToolsConfig(args: {
107
95
  runtime: RuntimeConfig | null;
108
96
  }): {
@@ -111,20 +99,18 @@ export declare function resolveToolsConfig(args: {
111
99
  };
112
100
  };
113
101
  export declare function resolveRuntime(args: {
114
- assessmentId: string;
115
102
  runtime: RuntimeConfig | null;
116
103
  effectiveToolsConfig: unknown;
117
104
  toolConfigStrictness?: ToolConfigStrictness;
118
- onFrameworkError?: FrameworkErrorHandler;
119
- onStageChange?: StageChangeHandler;
120
- onLoadingComplete?: LoadingCompleteHandler;
121
105
  }): {
122
- assessmentId: string | undefined;
123
106
  playerType: string;
124
107
  player: {
125
- [key: string]: unknown;
108
+ /** The host has already loaded the item bundles; the player loads none. */
109
+ hosted?: boolean;
126
110
  loaderConfig?: LoaderConfig;
127
111
  loaderOptions?: Record<string, unknown>;
112
+ /** The item player's `backend` config, passed through unread. */
113
+ backend?: Record<string, unknown> | null;
128
114
  } | null;
129
115
  lazyInit: boolean;
130
116
  accessibility: Record<string, unknown> | null;
@@ -132,39 +118,25 @@ export declare function resolveRuntime(args: {
132
118
  createSectionController: unknown;
133
119
  isolation: string;
134
120
  env: Record<string, unknown>;
135
- toolConfigStrictness: "off" | "error" | "warn";
136
- onFrameworkError: FrameworkErrorHandler | undefined;
137
- onStageChange: StageChangeHandler | undefined;
138
- onLoadingComplete: LoadingCompleteHandler | undefined;
121
+ toolConfigStrictness: ToolConfigStrictness;
139
122
  tools: unknown;
123
+ assessmentId?: string;
140
124
  toolContextResolvers?: Record<string, unknown> | null;
141
125
  /**
142
- * Presentation flag: opt-in to the vendored `<nds-icon-button>` for the
143
- * toolbar tool buttons, the calculator shell controls, inline-TTS
144
- * play/pause, and the section scroll-hint. NDS icons render only when
145
- * this is explicitly `true`; unset/`false` keeps the plain `<button>`
146
- * markup (the default). Purely visual — no engine effect.
147
- */
148
- ndsIcons?: boolean;
149
- /**
150
- * Interface locale: a BCP-47 tag naming the language the player renders its own
151
- * UI in. Purely presentational — no engine effect.
126
+ * Content language: a BCP-47 tag naming the language the authored content is
127
+ * written in, which read-aloud speaks it in and catalog lookups select
128
+ * alternates by. A `lang` in the content's markup wins over it. Purely
129
+ * presentational — no engine effect.
152
130
  *
153
- * Distinct from content language, which describes the authored item and
154
- * travels on `env`. QTI 3's implementation guide states the independence
155
- * directly: a candidate may choose an interface language which may or may not
156
- * also be the language of the content.
157
- *
158
- * Unset renders `en-US`. POSIX (`nl_NL`) and bare (`nl`) forms both resolve.
131
+ * Unset reads as `en-US` wherever the markup names no language.
159
132
  */
160
- locale?: string;
133
+ contentLanguage?: string;
134
+ onFrameworkError?: FrameworkErrorHandler;
135
+ /** Called with each `pie-stage-change` detail. */
136
+ onStageChange?: StageChangeHandler;
137
+ /** Called with each `pie-loading-complete` detail. */
138
+ onLoadingComplete?: LoadingCompleteHandler;
161
139
  };
162
- /**
163
- * Effective runtime returned by `resolveRuntime`. The shape is exposed
164
- * as `unknown` at the public boundary because consumers spread it into
165
- * arbitrary host props; downstream call sites narrow with the specific
166
- * keys they need.
167
- */
168
140
  export type EffectiveRuntime = ReturnType<typeof resolveRuntime>;
169
141
  /**
170
142
  * Engine-side orchestrator that powers `resolveSectionPlayerRuntimeState`