@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,92 +0,0 @@
1
- /**
2
- * Coordinator bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Unlike the DOM / framework-error bridges (which translate
6
- * **outputs** into I/O), the coordinator bridge is an **input source**:
7
- * it listens to a `ToolkitCoordinator` and feeds the resulting events
8
- * into the core via the `dispatchCoreInput` callback supplied by the
9
- * adapter.
10
- *
11
- * Responsibilities:
12
- * 1. **Framework-error subscription.** When the coordinator reports
13
- * a framework error through its bus, dispatch a
14
- * `{ kind: "framework-error" }` core input. Listener isolation
15
- * matches `FrameworkErrorBus`: a throwing bridge handler is
16
- * caught and `console.warn`-logged so the original fan-out is
17
- * not interrupted.
18
- *
19
- * 2. **Section-controller resolution.** When the host calls
20
- * `resolveSectionController({ ... })`, the bridge invokes
21
- * `coordinator.getOrCreateSectionController({ ... })` and, on
22
- * successful resolution, dispatches
23
- * `{ kind: "section-controller-resolved" }` to the core. Init
24
- * tokens guard against late resolutions overwriting a more
25
- * recent cohort (mirrors `SectionRuntimeEngine.initialize`'s
26
- * `activeInitToken` pattern).
27
- *
28
- * 3. **Disposal.** On `dispose()`, the bridge unsubscribes from the
29
- * framework-error bus and (if the engine owns the section
30
- * controller for the cohort) calls
31
- * `coordinator.disposeSectionController({ ... })`. It does
32
- * **not** dispose the coordinator itself — the coordinator's
33
- * lifetime is owned by the toolkit CE / host, not by the engine.
34
- *
35
- * Disposal is idempotent: calling `dispose()` twice is a no-op.
36
- *
37
- * The bridge **must not** import `svelte`.
38
- */
39
- import type { SectionControllerHandle } from "../../services/section-controller-types.js";
40
- import type { CohortKey } from "../core/cohort.js";
41
- import type { SectionEngineInput } from "../core/engine-input.js";
42
- /**
43
- * Subset of the `ToolkitCoordinator` surface the bridge consumes. Kept
44
- * structural so tests can pass a fake without pulling the full
45
- * coordinator.
46
- */
47
- export interface CoordinatorPort {
48
- subscribeFrameworkErrors(listener: (model: import("../../services/framework-error.js").FrameworkErrorModel) => void): () => void;
49
- getOrCreateSectionController(args: {
50
- sectionId: string;
51
- attemptId?: string;
52
- input?: unknown;
53
- updateExisting?: boolean;
54
- createDefaultController: () => SectionControllerHandle | Promise<SectionControllerHandle>;
55
- }): Promise<SectionControllerHandle>;
56
- disposeSectionController(args: {
57
- sectionId: string;
58
- attemptId?: string;
59
- }): Promise<void>;
60
- }
61
- export interface ResolveSectionControllerArgs {
62
- cohort: CohortKey;
63
- assessmentId: string;
64
- view: string;
65
- section: unknown;
66
- createDefaultController: () => SectionControllerHandle | Promise<SectionControllerHandle>;
67
- /**
68
- * Optional callback invoked when the controller resolves and on
69
- * every controller `subscribe` event. The kernel uses this to keep
70
- * its composition snapshot in sync with the controller's view.
71
- *
72
- * The bridge is responsible for unsubscribing on dispose / cohort
73
- * change so a stale controller doesn't keep emitting after rollover.
74
- */
75
- onCompositionChanged?: (composition: unknown) => void;
76
- /**
77
- * Optional callback invoked once with the resolved controller handle
78
- * the moment it is available. Lets the host keep a reference for
79
- * direct method calls (e.g. `navigateToItem`, `applySession`)
80
- * without re-querying the coordinator.
81
- */
82
- onControllerResolved?: (controller: SectionControllerHandle) => void;
83
- }
84
- export interface CoordinatorBridgeOptions {
85
- coordinator: CoordinatorPort;
86
- dispatchCoreInput: (input: SectionEngineInput) => void;
87
- }
88
- export interface CoordinatorBridgeHandle {
89
- resolveSectionController(args: ResolveSectionControllerArgs): Promise<void>;
90
- dispose(): Promise<void>;
91
- }
92
- export declare function createCoordinatorBridge(options: CoordinatorBridgeOptions): CoordinatorBridgeHandle;
@@ -1,126 +0,0 @@
1
- /**
2
- * Coordinator bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Unlike the DOM / framework-error bridges (which translate
6
- * **outputs** into I/O), the coordinator bridge is an **input source**:
7
- * it listens to a `ToolkitCoordinator` and feeds the resulting events
8
- * into the core via the `dispatchCoreInput` callback supplied by the
9
- * adapter.
10
- *
11
- * Responsibilities:
12
- * 1. **Framework-error subscription.** When the coordinator reports
13
- * a framework error through its bus, dispatch a
14
- * `{ kind: "framework-error" }` core input. Listener isolation
15
- * matches `FrameworkErrorBus`: a throwing bridge handler is
16
- * caught and `console.warn`-logged so the original fan-out is
17
- * not interrupted.
18
- *
19
- * 2. **Section-controller resolution.** When the host calls
20
- * `resolveSectionController({ ... })`, the bridge invokes
21
- * `coordinator.getOrCreateSectionController({ ... })` and, on
22
- * successful resolution, dispatches
23
- * `{ kind: "section-controller-resolved" }` to the core. Init
24
- * tokens guard against late resolutions overwriting a more
25
- * recent cohort (mirrors `SectionRuntimeEngine.initialize`'s
26
- * `activeInitToken` pattern).
27
- *
28
- * 3. **Disposal.** On `dispose()`, the bridge unsubscribes from the
29
- * framework-error bus and (if the engine owns the section
30
- * controller for the cohort) calls
31
- * `coordinator.disposeSectionController({ ... })`. It does
32
- * **not** dispose the coordinator itself — the coordinator's
33
- * lifetime is owned by the toolkit CE / host, not by the engine.
34
- *
35
- * Disposal is idempotent: calling `dispose()` twice is a no-op.
36
- *
37
- * The bridge **must not** import `svelte`.
38
- */
39
- export function createCoordinatorBridge(options) {
40
- const { coordinator, dispatchCoreInput } = options;
41
- let activeInitToken = 0;
42
- let activeCohort = null;
43
- let unsubscribeController = null;
44
- let disposed = false;
45
- const unsubscribeFrameworkErrors = coordinator.subscribeFrameworkErrors((model) => {
46
- try {
47
- dispatchCoreInput({ kind: "framework-error", error: model });
48
- }
49
- catch (error) {
50
- console.warn("[CoordinatorBridge] framework-error dispatch failed:", error);
51
- }
52
- });
53
- function detachControllerSubscription() {
54
- if (!unsubscribeController)
55
- return;
56
- try {
57
- unsubscribeController();
58
- }
59
- catch (error) {
60
- console.warn("[CoordinatorBridge] controller unsubscribe failed:", error);
61
- }
62
- unsubscribeController = null;
63
- }
64
- async function resolveSectionController(args) {
65
- if (disposed)
66
- return;
67
- activeInitToken += 1;
68
- const token = activeInitToken;
69
- activeCohort = args.cohort;
70
- const controller = await coordinator.getOrCreateSectionController({
71
- sectionId: args.cohort.sectionId,
72
- attemptId: args.cohort.attemptId || undefined,
73
- input: {
74
- section: args.section,
75
- sectionId: args.cohort.sectionId,
76
- assessmentId: args.assessmentId,
77
- view: args.view,
78
- },
79
- updateExisting: true,
80
- createDefaultController: args.createDefaultController,
81
- });
82
- // Drop late resolutions — a cohort change or dispose may have
83
- // rolled the token forward while we awaited the coordinator.
84
- if (token !== activeInitToken || disposed)
85
- return;
86
- detachControllerSubscription();
87
- args.onControllerResolved?.(controller);
88
- const getCompositionModel = controller.getCompositionModel;
89
- args.onCompositionChanged?.(getCompositionModel?.());
90
- if (typeof controller.subscribe === "function") {
91
- unsubscribeController = controller.subscribe((_event) => {
92
- if (token !== activeInitToken || disposed)
93
- return;
94
- args.onCompositionChanged?.(getCompositionModel?.());
95
- });
96
- }
97
- dispatchCoreInput({ kind: "section-controller-resolved" });
98
- }
99
- async function dispose() {
100
- if (disposed)
101
- return;
102
- disposed = true;
103
- activeInitToken += 1;
104
- detachControllerSubscription();
105
- try {
106
- unsubscribeFrameworkErrors();
107
- }
108
- catch (error) {
109
- console.warn("[CoordinatorBridge] framework-error unsubscribe failed:", error);
110
- }
111
- const cohort = activeCohort;
112
- activeCohort = null;
113
- if (cohort) {
114
- try {
115
- await coordinator.disposeSectionController({
116
- sectionId: cohort.sectionId,
117
- attemptId: cohort.attemptId || undefined,
118
- });
119
- }
120
- catch (error) {
121
- console.warn("[CoordinatorBridge] section-controller dispose failed:", error);
122
- }
123
- }
124
- }
125
- return { resolveSectionController, dispose };
126
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Framework-error bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Routes `framework-error` engine outputs into a `FrameworkErrorBus`
6
- * (write side: `FrameworkErrorReporter`). The bus is the single
7
- * fan-out point shared with the toolkit CE's banner, the coordinator's
8
- * canonical `onFrameworkError` lifecycle hook, and any direct host
9
- * subscribers via `subscribeFrameworkErrors`. See
10
- * `packages/assessment-toolkit/src/services/framework-error-bus.ts`
11
- * for the full bus contract.
12
- *
13
- * **Why a separate bridge.** The dom-event-bridge dispatches the
14
- * `framework-error` DOM event on the host. The framework-error-bridge
15
- * routes the same model into the in-process bus so listeners that
16
- * subscribe via `coordinator.subscribeFrameworkErrors(...)` see the
17
- * same fan-out with byte-identical payloads. Splitting the
18
- * responsibilities lets a host opt out of either side (DOM-only or
19
- * bus-only) without re-implementing the other.
20
- *
21
- * **Bus ownership.** The bridge does not construct the bus; the
22
- * adapter receives one externally so the toolkit CE can keep sharing
23
- * its bus with the coordinator (matching today's
24
- * `PieAssessmentToolkit.svelte` lifetime model). This avoids the
25
- * "second bus" pitfall — a dual-bus topology would silently fragment
26
- * fan-out.
27
- */
28
- import type { FrameworkErrorReporter } from "../../services/framework-error-bus.js";
29
- import type { SectionEngineOutput } from "../core/engine-output.js";
30
- export interface FrameworkErrorBridgeOptions {
31
- bus: FrameworkErrorReporter;
32
- }
33
- export interface FrameworkErrorBridgeHandle {
34
- dispatch(output: SectionEngineOutput): void;
35
- }
36
- export declare function createFrameworkErrorBridge(options: FrameworkErrorBridgeOptions): FrameworkErrorBridgeHandle;
@@ -1,46 +0,0 @@
1
- /**
2
- * Framework-error bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Routes `framework-error` engine outputs into a `FrameworkErrorBus`
6
- * (write side: `FrameworkErrorReporter`). The bus is the single
7
- * fan-out point shared with the toolkit CE's banner, the coordinator's
8
- * canonical `onFrameworkError` lifecycle hook, and any direct host
9
- * subscribers via `subscribeFrameworkErrors`. See
10
- * `packages/assessment-toolkit/src/services/framework-error-bus.ts`
11
- * for the full bus contract.
12
- *
13
- * **Why a separate bridge.** The dom-event-bridge dispatches the
14
- * `framework-error` DOM event on the host. The framework-error-bridge
15
- * routes the same model into the in-process bus so listeners that
16
- * subscribe via `coordinator.subscribeFrameworkErrors(...)` see the
17
- * same fan-out with byte-identical payloads. Splitting the
18
- * responsibilities lets a host opt out of either side (DOM-only or
19
- * bus-only) without re-implementing the other.
20
- *
21
- * **Bus ownership.** The bridge does not construct the bus; the
22
- * adapter receives one externally so the toolkit CE can keep sharing
23
- * its bus with the coordinator (matching today's
24
- * `PieAssessmentToolkit.svelte` lifetime model). This avoids the
25
- * "second bus" pitfall — a dual-bus topology would silently fragment
26
- * fan-out.
27
- */
28
- export function createFrameworkErrorBridge(options) {
29
- const { bus } = options;
30
- function dispatch(output) {
31
- switch (output.kind) {
32
- case "framework-error":
33
- bus.reportFrameworkError(output.error);
34
- return;
35
- case "stage-change":
36
- case "loading-complete":
37
- return;
38
- default: {
39
- const exhaustive = output;
40
- void exhaustive;
41
- return;
42
- }
43
- }
44
- }
45
- return { dispatch };
46
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Instrumentation bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Forwards every `SectionEngineOutput` to an optional observability
6
- * hook the host injects (telemetry, debug logger, e2e probe). The
7
- * bridge is intentionally thin: it does not buffer, transform, or
8
- * filter. Hosts that need a different shape can run their own subscriber
9
- * via the adapter's public `subscribe(...)` channel.
10
- *
11
- * **Why a dedicated bridge instead of a generic subscriber.** The
12
- * subscriber-fanout channel is host-shaped — listeners receive batched
13
- * arrays of outputs per `core.dispatch` call so they can reason about
14
- * "what happened in this transition." The instrumentation hook is
15
- * per-output: telemetry pipelines want one record per stage change,
16
- * one record per readiness flip, etc. Splitting the channels keeps
17
- * both shapes ergonomic.
18
- *
19
- * The bridge **must not** import `svelte` per the M7 layering
20
- * constraint.
21
- */
22
- import type { SectionEngineOutput } from "../core/engine-output.js";
23
- export type InstrumentationHook = (output: SectionEngineOutput) => void;
24
- export interface InstrumentationBridgeOptions {
25
- hook?: InstrumentationHook;
26
- }
27
- export interface InstrumentationBridgeHandle {
28
- dispatch(output: SectionEngineOutput): void;
29
- setHook(hook: InstrumentationHook | undefined): void;
30
- }
31
- export declare function createInstrumentationBridge(options?: InstrumentationBridgeOptions): InstrumentationBridgeHandle;
@@ -1,38 +0,0 @@
1
- /**
2
- * Instrumentation bridge for the section runtime engine adapter (M7 —
3
- * Variant C, layered).
4
- *
5
- * Forwards every `SectionEngineOutput` to an optional observability
6
- * hook the host injects (telemetry, debug logger, e2e probe). The
7
- * bridge is intentionally thin: it does not buffer, transform, or
8
- * filter. Hosts that need a different shape can run their own subscriber
9
- * via the adapter's public `subscribe(...)` channel.
10
- *
11
- * **Why a dedicated bridge instead of a generic subscriber.** The
12
- * subscriber-fanout channel is host-shaped — listeners receive batched
13
- * arrays of outputs per `core.dispatch` call so they can reason about
14
- * "what happened in this transition." The instrumentation hook is
15
- * per-output: telemetry pipelines want one record per stage change,
16
- * one record per readiness flip, etc. Splitting the channels keeps
17
- * both shapes ergonomic.
18
- *
19
- * The bridge **must not** import `svelte` per the M7 layering
20
- * constraint.
21
- */
22
- export function createInstrumentationBridge(options = {}) {
23
- let hook = options.hook;
24
- function dispatch(output) {
25
- if (!hook)
26
- return;
27
- try {
28
- hook(output);
29
- }
30
- catch (error) {
31
- console.warn("[InstrumentationBridge] hook failed:", error);
32
- }
33
- }
34
- function setHook(next) {
35
- hook = next;
36
- }
37
- return { dispatch, setHook };
38
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Stage derivation for the section runtime engine (M7).
3
- *
4
- * Maps the FSM phase onto the canonical M6 stage vocabulary
5
- * (`composed`, `engine-ready`, `interactive`, `disposed`). The phase
6
- * `idle` is the engine's "no cohort yet" state and has no stage; it
7
- * returns `null`.
8
- *
9
- * This module exists as a one-line indirection because:
10
- * - The adapter uses it to guard `pie-stage-change` emit calls.
11
- * - The transition uses it (via the pure helper below) to decide
12
- * when to emit `stage-change` outputs as the phase advances.
13
- * - Future shape-specific stages (e.g. layout-only `paginated`) can
14
- * be wired in here without rewriting callers.
15
- */
16
- import type { Stage } from "@pie-players/pie-players-shared/pie";
17
- import type { SectionEnginePhase } from "./engine-state.js";
18
- export declare function phaseToStage(phase: SectionEnginePhase): Stage | null;
@@ -1,29 +0,0 @@
1
- /**
2
- * Stage derivation for the section runtime engine (M7).
3
- *
4
- * Maps the FSM phase onto the canonical M6 stage vocabulary
5
- * (`composed`, `engine-ready`, `interactive`, `disposed`). The phase
6
- * `idle` is the engine's "no cohort yet" state and has no stage; it
7
- * returns `null`.
8
- *
9
- * This module exists as a one-line indirection because:
10
- * - The adapter uses it to guard `pie-stage-change` emit calls.
11
- * - The transition uses it (via the pure helper below) to decide
12
- * when to emit `stage-change` outputs as the phase advances.
13
- * - Future shape-specific stages (e.g. layout-only `paginated`) can
14
- * be wired in here without rewriting callers.
15
- */
16
- export function phaseToStage(phase) {
17
- switch (phase) {
18
- case "idle":
19
- return null;
20
- case "booting-section":
21
- return "composed";
22
- case "engine-ready":
23
- return "engine-ready";
24
- case "interactive":
25
- return "interactive";
26
- case "disposed":
27
- return "disposed";
28
- }
29
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * Svelte context key for the section runtime engine (M7 PR 5).
3
- *
4
- * Components inside a section player layout consume the engine through
5
- * Svelte's native `getContext(SECTION_RUNTIME_ENGINE_KEY)`. The kernel
6
- * (`SectionPlayerLayoutKernel.svelte`) is the canonical provider — it
7
- * constructs the engine, attaches it to the layout CE host, and exposes
8
- * it to descendants via `setContext(SECTION_RUNTIME_ENGINE_KEY, engine)`.
9
- *
10
- * The contract is one-directional:
11
- * - Provider: the component that owns engine lifetime (kernel today;
12
- * in M7 PR 6 the toolkit CE will fall back to constructing its own
13
- * engine when no upstream provider is present).
14
- * - Consumers: any descendant Svelte component that needs to read
15
- * state, subscribe to outputs, or feed inputs (e.g. the toolkit CE
16
- * reaching the engine through the wrapping kernel).
17
- *
18
- * The key is a `Symbol` so it cannot collide with userland context keys
19
- * and so descendants are forced to import this module rather than
20
- * guess a string id.
21
- *
22
- * **Stability.** This export is part of the stable runtime/engine
23
- * surface; renaming or replacing the symbol is a major breaking
24
- * change. Adding adjacent context keys (e.g. for dedicated read-only
25
- * snapshots) is allowed.
26
- */
27
- import type { SectionRuntimeEngine } from "./SectionRuntimeEngine.js";
28
- /**
29
- * Svelte context key under which a `SectionRuntimeEngine` instance is
30
- * provided to descendants.
31
- */
32
- export declare const SECTION_RUNTIME_ENGINE_KEY: unique symbol;
33
- /**
34
- * Type-level alias for the value stored under
35
- * `SECTION_RUNTIME_ENGINE_KEY`. Exposed as a separate alias so
36
- * consumers can spell the type without importing the implementing
37
- * class directly.
38
- */
39
- export type SectionRuntimeEngineContext = SectionRuntimeEngine;
@@ -1,31 +0,0 @@
1
- /**
2
- * Svelte context key for the section runtime engine (M7 PR 5).
3
- *
4
- * Components inside a section player layout consume the engine through
5
- * Svelte's native `getContext(SECTION_RUNTIME_ENGINE_KEY)`. The kernel
6
- * (`SectionPlayerLayoutKernel.svelte`) is the canonical provider — it
7
- * constructs the engine, attaches it to the layout CE host, and exposes
8
- * it to descendants via `setContext(SECTION_RUNTIME_ENGINE_KEY, engine)`.
9
- *
10
- * The contract is one-directional:
11
- * - Provider: the component that owns engine lifetime (kernel today;
12
- * in M7 PR 6 the toolkit CE will fall back to constructing its own
13
- * engine when no upstream provider is present).
14
- * - Consumers: any descendant Svelte component that needs to read
15
- * state, subscribe to outputs, or feed inputs (e.g. the toolkit CE
16
- * reaching the engine through the wrapping kernel).
17
- *
18
- * The key is a `Symbol` so it cannot collide with userland context keys
19
- * and so descendants are forced to import this module rather than
20
- * guess a string id.
21
- *
22
- * **Stability.** This export is part of the stable runtime/engine
23
- * surface; renaming or replacing the symbol is a major breaking
24
- * change. Adding adjacent context keys (e.g. for dedicated read-only
25
- * snapshots) is allowed.
26
- */
27
- /**
28
- * Svelte context key under which a `SectionRuntimeEngine` instance is
29
- * provided to descendants.
30
- */
31
- export const SECTION_RUNTIME_ENGINE_KEY = Symbol("@pie-players/section-runtime-engine");
@@ -1,43 +0,0 @@
1
- /**
2
- * Section runtime engine — **internal** entry point (M7 — Variant C).
3
- *
4
- * Re-exports the layered core + adapter surface for advanced hosts that
5
- * want to construct or inspect engines directly, and for the engine's
6
- * own tests / benchmarks.
7
- *
8
- * **Stability posture.** This module is **not** part of the stable
9
- * public API. Symbols here are subject to change between minor versions
10
- * with only a changeset note. Hosts that need long-term stability
11
- * should depend on the facade (`SectionRuntimeEngine` exported from
12
- * `./runtime/engine`) instead.
13
- *
14
- * The split is intentional:
15
- * - `./runtime/engine` (PR 3) — narrow, stable facade for common
16
- * host wiring.
17
- * - `./runtime/internal` — wide, evolving surface for the kernel,
18
- * adapter tests, and any host that wants to reach past the facade.
19
- *
20
- * The `runtime/engine` and `runtime/internal` package `exports` map
21
- * entries are added in PR 3 alongside the facade refactor.
22
- */
23
- export { SectionEngineAdapter } from "./adapter/SectionEngineAdapter.js";
24
- export type { SectionEngineAdapterOptions } from "./adapter/SectionEngineAdapter.js";
25
- export { FrameworkErrorBus, type FrameworkErrorListener, type FrameworkErrorPort, type FrameworkErrorReporter, } from "../services/framework-error-bus.js";
26
- export { createCoordinatorBridge, type CoordinatorBridgeHandle, type CoordinatorBridgeOptions, type CoordinatorPort, type ResolveSectionControllerArgs, } from "./adapter/coordinator-bridge.js";
27
- export { createDomEventBridge, type DomEventBridgeHandle, type DomEventBridgeOptions, } from "./adapter/dom-event-bridge.js";
28
- export { createFrameworkErrorBridge, type FrameworkErrorBridgeHandle, type FrameworkErrorBridgeOptions, } from "./adapter/framework-error-bridge.js";
29
- export { createInstrumentationBridge, type InstrumentationBridgeHandle, type InstrumentationBridgeOptions, type InstrumentationHook, } from "./adapter/instrumentation-bridge.js";
30
- export { createSubscriberFanout, type EngineOutputListener, type SubscriberFanoutHandle, } from "./adapter/subscriber-fanout.js";
31
- export { SectionEngineCore } from "./core/SectionEngineCore.js";
32
- export type { SectionEngineCoreListener } from "./core/SectionEngineCore.js";
33
- export { cohortKey, cohortsEqual, makeCohort, type CohortKey, } from "./core/cohort.js";
34
- export type { SectionEngineInput } from "./core/engine-input.js";
35
- export type { SectionEngineOutput } from "./core/engine-output.js";
36
- export type { EngineReadinessDetail, EngineReadinessPhase, EngineReadinessSignals, } from "./core/engine-readiness.js";
37
- export type { SectionEnginePhase, SectionEngineState, } from "./core/engine-state.js";
38
- export { createInitialEngineState } from "./core/engine-state.js";
39
- export { phaseToStage } from "./core/engine-stage-derivation.js";
40
- export { DEFAULT_ASSESSMENT_ID, DEFAULT_ENV, DEFAULT_ISOLATION, DEFAULT_LAZY_INIT, DEFAULT_PLAYER_TYPE, resolveOnFrameworkError, resolveRuntime, resolveSectionEngineRuntimeState, resolveToolsConfig, type EffectiveRuntime, type FrameworkErrorHandler, type LoadingCompleteHandler, type PlayerOverrides, type RuntimeConfig, type RuntimeInputs, type StageChangeHandler, } from "./core/engine-resolver.js";
41
- export { createReadinessDetail, resolveReadinessPhase, } from "./core/engine-readiness.js";
42
- export { transition } from "./core/engine-transition.js";
43
- export type { TransitionResult } from "./core/engine-transition.js";
@@ -1,45 +0,0 @@
1
- /**
2
- * Section runtime engine — **internal** entry point (M7 — Variant C).
3
- *
4
- * Re-exports the layered core + adapter surface for advanced hosts that
5
- * want to construct or inspect engines directly, and for the engine's
6
- * own tests / benchmarks.
7
- *
8
- * **Stability posture.** This module is **not** part of the stable
9
- * public API. Symbols here are subject to change between minor versions
10
- * with only a changeset note. Hosts that need long-term stability
11
- * should depend on the facade (`SectionRuntimeEngine` exported from
12
- * `./runtime/engine`) instead.
13
- *
14
- * The split is intentional:
15
- * - `./runtime/engine` (PR 3) — narrow, stable facade for common
16
- * host wiring.
17
- * - `./runtime/internal` — wide, evolving surface for the kernel,
18
- * adapter tests, and any host that wants to reach past the facade.
19
- *
20
- * The `runtime/engine` and `runtime/internal` package `exports` map
21
- * entries are added in PR 3 alongside the facade refactor.
22
- */
23
- export { SectionEngineAdapter } from "./adapter/SectionEngineAdapter.js";
24
- // `FrameworkErrorBus` is the package-internal multi-subscriber bus the
25
- // engine adapter consumes via the `FrameworkErrorReporter` write port.
26
- // It is re-exported here (alongside the read/write ports) so advanced
27
- // hosts that construct an engine instance directly — including the M7
28
- // PR 5 section-player kernel — can wire a bus without reaching into a
29
- // deep relative path. The class itself remains "package-internal" in
30
- // posture (the doc comment on the class explains why); this export is
31
- // a deliberate, advanced-host escape hatch on the evolving
32
- // `runtime/internal` surface, never on the stable facade.
33
- export { FrameworkErrorBus, } from "../services/framework-error-bus.js";
34
- export { createCoordinatorBridge, } from "./adapter/coordinator-bridge.js";
35
- export { createDomEventBridge, } from "./adapter/dom-event-bridge.js";
36
- export { createFrameworkErrorBridge, } from "./adapter/framework-error-bridge.js";
37
- export { createInstrumentationBridge, } from "./adapter/instrumentation-bridge.js";
38
- export { createSubscriberFanout, } from "./adapter/subscriber-fanout.js";
39
- export { SectionEngineCore } from "./core/SectionEngineCore.js";
40
- export { cohortKey, cohortsEqual, makeCohort, } from "./core/cohort.js";
41
- export { createInitialEngineState } from "./core/engine-state.js";
42
- export { phaseToStage } from "./core/engine-stage-derivation.js";
43
- export { DEFAULT_ASSESSMENT_ID, DEFAULT_ENV, DEFAULT_ISOLATION, DEFAULT_LAZY_INIT, DEFAULT_PLAYER_TYPE, resolveOnFrameworkError, resolveRuntime, resolveSectionEngineRuntimeState, resolveToolsConfig, } from "./core/engine-resolver.js";
44
- export { createReadinessDetail, resolveReadinessPhase, } from "./core/engine-readiness.js";
45
- export { transition } from "./core/engine-transition.js";
@@ -1,80 +0,0 @@
1
- /**
2
- * Cross-Custom-Element context for the section runtime engine (M7 PR 6).
3
- *
4
- * The toolkit CE renders inside its own Shadow DOM, so Svelte's native
5
- * `setContext`/`getContext` (used by `engine-context.ts`) cannot bridge
6
- * the kernel-provided engine reference to the toolkit's component tree.
7
- * This module exposes a `@pie-players/pie-context` based context that
8
- * does cross the CE boundary via DOM events:
9
- *
10
- * - The kernel (`SectionPlayerLayoutKernel.svelte`) installs a
11
- * `ContextProvider` for `sectionRuntimeEngineHostContext` on its
12
- * `host` (the layout CE). The provider value carries a narrow
13
- * lifecycle handle for the engine owned by that kernel mount.
14
- * - The toolkit CE installs a `ContextConsumer` on its own host. When
15
- * wrapped by a section player layout, the consumer resolves to the
16
- * kernel's lifecycle handle and suppresses its standalone lifecycle
17
- * DOM emits in favor of the section-player host. Controller-side
18
- * calls (`register`, `handleContent*`, `initialize`, etc.) remain
19
- * owned by the toolkit's locally-constructed engine. When
20
- * standalone, no host provider responds and the toolkit keeps using
21
- * its standalone lifecycle path.
22
- *
23
- * The two engine-context surfaces (`SECTION_RUNTIME_ENGINE_KEY` and
24
- * this one) are deliberately distinct:
25
- * - `SECTION_RUNTIME_ENGINE_KEY` (Svelte context) stays scoped to a
26
- * single component tree (kernel + descendants in the same shadow
27
- * root) and is the right hook for in-tree consumers.
28
- * - `sectionRuntimeEngineHostContext` (DOM-event context) is the
29
- * bridge for cross-CE consumers and only carries data that is safe
30
- * to share across CE boundaries (a stable lifecycle handle).
31
- *
32
- * **Stability.** This export is part of the stable runtime/engine
33
- * surface; the symbol identity and value shape are part of the
34
- * cross-CE contract. Renaming or replacing the symbol is a major
35
- * breaking change. Adding optional fields to the value shape is
36
- * allowed; required fields are not.
37
- */
38
- /**
39
- * Narrow cross-CE handle published by section-player. Deliberately omits
40
- * controller-facing methods (`initialize`, `register`, `handleContent*`,
41
- * etc.) so the package seam cannot grow an accidental controller contract.
42
- */
43
- export interface SectionRuntimeLifecycleHandle {
44
- getRuntimeId(): string;
45
- }
46
- /**
47
- * Value shape published by the kernel and consumed by the wrapped
48
- * toolkit CE. Carries only the lifecycle handle today; if more cross-CE
49
- * shared runtime state is needed later, fields can be added here
50
- * additively.
51
- */
52
- export interface SectionRuntimeEngineHostContextValue {
53
- engine: SectionRuntimeLifecycleHandle;
54
- }
55
- /**
56
- * `pie-context` context key for the cross-CE engine bridge. Uses a
57
- * `Symbol.for(...)` registry key so providers and consumers in
58
- * separately-bundled CEs see the same identity.
59
- */
60
- export declare const sectionRuntimeEngineHostContext: {
61
- __context__: SectionRuntimeEngineHostContextValue;
62
- };
63
- export type SectionRuntimeEngineHostContextListener = (value: SectionRuntimeEngineHostContextValue) => void;
64
- /**
65
- * Connect a DOM host to the cross-CE engine context with the same
66
- * provider-retry semantics used elsewhere in the toolkit (initial
67
- * synchronous request + `context-provider` re-request + 50 ms polling
68
- * fallback up to 200 attempts ≈ 10 s).
69
- *
70
- * The retry mirrors the existing
71
- * `connectAssessmentToolkitHostRuntimeContext` infrastructure so the
72
- * timing characteristics of cross-CE handshakes stay consistent across
73
- * the toolkit's contexts.
74
- *
75
- * Returns a cleanup function that disconnects the consumer and clears
76
- * the retry interval. Standalone toolkits naturally exhaust the retry
77
- * window without ever resolving and continue using their local
78
- * engine — that is by design and is not an error.
79
- */
80
- export declare function connectSectionRuntimeEngineHostContext(host: HTMLElement, onValue: SectionRuntimeEngineHostContextListener): () => void;