@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
@@ -0,0 +1,13 @@
1
+ import type { ToolkitCoordinatorApi } from "../services/interfaces.js";
2
+ import type { RuntimeRegistrationDetail } from "./registration-events.js";
3
+ /**
4
+ * What a content registration files with the coordinator: the content's
5
+ * accessibility catalogs, and an item's policy settings under its canonical
6
+ * id, the id its item-level toolbar scopes decisions by. Returns the cleanups
7
+ * that withdraw them, for the toolkit to run when the content unregisters or
8
+ * the coordinator changes.
9
+ */
10
+ export declare function registerContentWithCoordinator(coordinator: Pick<ToolkitCoordinatorApi, "catalogResolver" | "registerItemSettings">, detail: RuntimeRegistrationDetail, owner: {
11
+ assessmentId: string;
12
+ sectionId: string;
13
+ }): Array<() => void>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * What a content registration files with the coordinator: the content's
3
+ * accessibility catalogs, and an item's policy settings under its canonical
4
+ * id, the id its item-level toolbar scopes decisions by. Returns the cleanups
5
+ * that withdraw them, for the toolkit to run when the content unregisters or
6
+ * the coordinator changes.
7
+ */
8
+ export function registerContentWithCoordinator(coordinator, detail, owner) {
9
+ const cleanups = [
10
+ coordinator.catalogResolver.registerOwner({
11
+ owner: {
12
+ kind: detail.kind,
13
+ itemId: detail.itemId,
14
+ canonicalItemId: detail.canonicalItemId,
15
+ assessmentId: owner.assessmentId,
16
+ sectionId: owner.sectionId,
17
+ },
18
+ entity: detail.item,
19
+ }),
20
+ ];
21
+ if (detail.kind === "item" && detail.settings) {
22
+ cleanups.push(coordinator.registerItemSettings(detail.canonicalItemId || detail.itemId, detail.settings));
23
+ }
24
+ return cleanups;
25
+ }
@@ -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
@@ -45,7 +45,5 @@ export declare class SectionEngineCore {
45
45
  * construction time if you need every output from `idle` onward.
46
46
  */
47
47
  subscribe(listener: SectionEngineCoreListener): () => void;
48
- /** Test-only: detach every listener. */
49
- disposeListeners(): void;
50
48
  private fanOut;
51
49
  }
@@ -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
@@ -61,10 +61,6 @@ export class SectionEngineCore {
61
61
  this.listeners.delete(listener);
62
62
  };
63
63
  }
64
- /** Test-only: detach every listener. */
65
- disposeListeners() {
66
- this.listeners.clear();
67
- }
68
64
  fanOut(outputs) {
69
65
  const snapshot = Array.from(this.listeners);
70
66
  const frozen = Object.freeze(outputs.slice());
@@ -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
@@ -17,11 +17,6 @@ export interface CohortKey {
17
17
  /** Attempt identifier; empty string if the host did not provide one. */
18
18
  attemptId: string;
19
19
  }
20
- /**
21
- * Stable string form of the cohort tuple used as a key for the
22
- * `loadingCompleteEmittedForCohort` latch and equality checks.
23
- */
24
- export declare function cohortKey(cohort: CohortKey | null): string;
25
20
  /**
26
21
  * `true` iff the two cohorts have the same `(sectionId, attemptId)` pair.
27
22
  * Treats both inputs as identifying the cohort by value, never by
@@ -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
@@ -11,15 +11,6 @@
11
11
  * layout-CE prop shape) but the engine carries it as the empty string
12
12
  * when absent so the cohort key is total.
13
13
  */
14
- /**
15
- * Stable string form of the cohort tuple used as a key for the
16
- * `loadingCompleteEmittedForCohort` latch and equality checks.
17
- */
18
- export function cohortKey(cohort) {
19
- if (!cohort)
20
- return "";
21
- return `${cohort.sectionId}|${cohort.attemptId}`;
22
- }
23
14
  /**
24
15
  * `true` iff the two cohorts have the same `(sectionId, attemptId)` pair.
25
16
  * Treats both inputs as identifying the cohort by value, never by
@@ -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,14 @@ 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`: section ready plus the host's
30
+ * loading signal, which the section player kernel raises once the element
31
+ * pre-warm resolves. `itemCount` is the composition's item count.
45
32
  */
46
33
  export type EngineOutputLoadingComplete = {
47
34
  kind: "loading-complete";
48
35
  cohort: CohortKey;
49
36
  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
37
  };
61
- export type SectionEngineOutput = EngineOutputStageChange | EngineOutputLoadingComplete | EngineOutputFrameworkError;
38
+ 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
  }