@pie-players/pie-assessment-toolkit 0.3.43 → 0.3.44

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 (317) hide show
  1. package/dist/attempt/AssessmentSession.d.ts +0 -1
  2. package/dist/attempt/AssessmentSession.js.map +1 -1
  3. package/dist/attempt/TestSession.d.ts +0 -1
  4. package/dist/attempt/TestSession.js.map +1 -1
  5. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -1
  6. package/dist/attempt/adapters/activity-to-test-attempt-session.js.map +1 -1
  7. package/dist/components/ItemToolBar.custom-element.js +1181 -157
  8. package/dist/components/SectionToolBar.custom-element.js +1179 -157
  9. package/dist/components/item-toolbar-element.d.ts +0 -1
  10. package/dist/components/item-toolbar-element.js.map +1 -1
  11. package/dist/components/pie-assessment-toolkit-element.d.ts +0 -1
  12. package/dist/components/pie-assessment-toolkit-element.js.map +1 -1
  13. package/dist/components/section-toolbar-element.d.ts +0 -1
  14. package/dist/components/section-toolbar-element.js.map +1 -1
  15. package/dist/components/vendor/nds/README.md +110 -0
  16. package/dist/components/vendor/nds/nds-icon-button.js +826 -0
  17. package/dist/context/assessment-toolkit-context.d.ts +0 -1
  18. package/dist/context/assessment-toolkit-context.js.map +1 -1
  19. package/dist/context/runtime-context-consumer.d.ts +0 -1
  20. package/dist/context/runtime-context-consumer.js.map +1 -1
  21. package/dist/index.d.ts +0 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/item-loader.d.ts +0 -1
  24. package/dist/item-loader.js.map +1 -1
  25. package/dist/policy/core/PolicySource.d.ts +0 -1
  26. package/dist/policy/core/PolicySource.js.map +1 -1
  27. package/dist/policy/core/ToolPolicyEngine.d.ts +0 -1
  28. package/dist/policy/core/ToolPolicyEngine.js.map +1 -1
  29. package/dist/policy/core/compose-decision.d.ts +0 -1
  30. package/dist/policy/core/compose-decision.js.map +1 -1
  31. package/dist/policy/core/decision-types.d.ts +0 -1
  32. package/dist/policy/core/decision-types.js.map +1 -1
  33. package/dist/policy/core/engine-context.d.ts +0 -1
  34. package/dist/policy/core/engine-context.js.map +1 -1
  35. package/dist/policy/core/pnp-policy-inputs.d.ts +0 -1
  36. package/dist/policy/core/pnp-policy-inputs.js.map +1 -1
  37. package/dist/policy/core/policy-source-tag.d.ts +0 -1
  38. package/dist/policy/core/policy-source-tag.js.map +1 -1
  39. package/dist/policy/core/provenance.d.ts +0 -1
  40. package/dist/policy/core/provenance.js.map +1 -1
  41. package/dist/policy/engine.d.ts +0 -1
  42. package/dist/policy/engine.js.map +1 -1
  43. package/dist/policy/internal.d.ts +0 -1
  44. package/dist/policy/internal.js.map +1 -1
  45. package/dist/policy/sources/PnpPolicySource.d.ts +0 -1
  46. package/dist/policy/sources/PnpPolicySource.js.map +1 -1
  47. package/dist/runtime/RuntimeRegistry.d.ts +0 -1
  48. package/dist/runtime/RuntimeRegistry.js.map +1 -1
  49. package/dist/runtime/SectionRuntimeEngine.d.ts +0 -1
  50. package/dist/runtime/SectionRuntimeEngine.js.map +1 -1
  51. package/dist/runtime/adapter/SectionEngineAdapter.d.ts +0 -1
  52. package/dist/runtime/adapter/SectionEngineAdapter.js.map +1 -1
  53. package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -1
  54. package/dist/runtime/adapter/coordinator-bridge.js.map +1 -1
  55. package/dist/runtime/adapter/dom-event-bridge.d.ts +0 -1
  56. package/dist/runtime/adapter/dom-event-bridge.js.map +1 -1
  57. package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -1
  58. package/dist/runtime/adapter/framework-error-bridge.js.map +1 -1
  59. package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -1
  60. package/dist/runtime/adapter/instrumentation-bridge.js.map +1 -1
  61. package/dist/runtime/adapter/subscriber-fanout.d.ts +0 -1
  62. package/dist/runtime/adapter/subscriber-fanout.js.map +1 -1
  63. package/dist/runtime/core/SectionEngineCore.d.ts +0 -1
  64. package/dist/runtime/core/SectionEngineCore.js.map +1 -1
  65. package/dist/runtime/core/cohort.d.ts +0 -1
  66. package/dist/runtime/core/cohort.js.map +1 -1
  67. package/dist/runtime/core/engine-input.d.ts +0 -1
  68. package/dist/runtime/core/engine-input.js.map +1 -1
  69. package/dist/runtime/core/engine-output.d.ts +0 -1
  70. package/dist/runtime/core/engine-output.js.map +1 -1
  71. package/dist/runtime/core/engine-readiness.d.ts +0 -1
  72. package/dist/runtime/core/engine-readiness.js.map +1 -1
  73. package/dist/runtime/core/engine-resolver.d.ts +0 -1
  74. package/dist/runtime/core/engine-resolver.js.map +1 -1
  75. package/dist/runtime/core/engine-stage-derivation.d.ts +0 -1
  76. package/dist/runtime/core/engine-stage-derivation.js.map +1 -1
  77. package/dist/runtime/core/engine-state.d.ts +0 -1
  78. package/dist/runtime/core/engine-state.js.map +1 -1
  79. package/dist/runtime/core/engine-transition.d.ts +0 -1
  80. package/dist/runtime/core/engine-transition.js.map +1 -1
  81. package/dist/runtime/engine-context.d.ts +0 -1
  82. package/dist/runtime/engine-context.js.map +1 -1
  83. package/dist/runtime/engine.d.ts +0 -1
  84. package/dist/runtime/engine.js.map +1 -1
  85. package/dist/runtime/internal.d.ts +0 -1
  86. package/dist/runtime/internal.js.map +1 -1
  87. package/dist/runtime/registration-events.d.ts +0 -1
  88. package/dist/runtime/registration-events.js.map +1 -1
  89. package/dist/runtime/runtime-id.d.ts +0 -1
  90. package/dist/runtime/runtime-id.js.map +1 -1
  91. package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -1
  92. package/dist/runtime/section-runtime-engine-host-context.js.map +1 -1
  93. package/dist/runtime/session-event-emitter-policy.d.ts +0 -1
  94. package/dist/runtime/session-event-emitter-policy.js.map +1 -1
  95. package/dist/runtime/stage-emit-gate.d.ts +0 -1
  96. package/dist/runtime/stage-emit-gate.js.map +1 -1
  97. package/dist/runtime/tool-host-contract.d.ts +0 -1
  98. package/dist/runtime/tool-host-contract.js.map +1 -1
  99. package/dist/services/AccessibilityCatalogResolver.d.ts +0 -1
  100. package/dist/services/AccessibilityCatalogResolver.js.map +1 -1
  101. package/dist/services/ContextVariableStore.d.ts +0 -1
  102. package/dist/services/ContextVariableStore.js.map +1 -1
  103. package/dist/services/ElementToolStateStore.d.ts +0 -1
  104. package/dist/services/ElementToolStateStore.js.map +1 -1
  105. package/dist/services/HighlightCoordinator.d.ts +0 -1
  106. package/dist/services/HighlightCoordinator.js.map +1 -1
  107. package/dist/services/I18nService.d.ts +0 -1
  108. package/dist/services/I18nService.js.map +1 -1
  109. package/dist/services/PNPToolResolver.d.ts +0 -1
  110. package/dist/services/PNPToolResolver.js.map +1 -1
  111. package/dist/services/RangeSerializer.d.ts +0 -1
  112. package/dist/services/RangeSerializer.js.map +1 -1
  113. package/dist/services/SSMLExtractor.d.ts +0 -1
  114. package/dist/services/SSMLExtractor.js.map +1 -1
  115. package/dist/services/TTSService.d.ts +0 -1
  116. package/dist/services/TTSService.js.map +1 -1
  117. package/dist/services/ThemeProvider.d.ts +0 -1
  118. package/dist/services/ThemeProvider.js.map +1 -1
  119. package/dist/services/ToolConfigResolver.d.ts +0 -1
  120. package/dist/services/ToolConfigResolver.js.map +1 -1
  121. package/dist/services/ToolCoordinator.d.ts +0 -1
  122. package/dist/services/ToolCoordinator.js.map +1 -1
  123. package/dist/services/ToolRegistry.d.ts +0 -1
  124. package/dist/services/ToolRegistry.js.map +1 -1
  125. package/dist/services/ToolkitCoordinator.d.ts +0 -1
  126. package/dist/services/ToolkitCoordinator.js.map +1 -1
  127. package/dist/services/create-tools-config.d.ts +0 -1
  128. package/dist/services/create-tools-config.js.map +1 -1
  129. package/dist/services/createDefaultToolRegistry.d.ts +0 -1
  130. package/dist/services/createDefaultToolRegistry.js.map +1 -1
  131. package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -1
  132. package/dist/services/defaultPersonalNeedsProfile.js.map +1 -1
  133. package/dist/services/framework-error-bus.d.ts +0 -1
  134. package/dist/services/framework-error-bus.js.map +1 -1
  135. package/dist/services/framework-error.d.ts +0 -1
  136. package/dist/services/framework-error.js.map +1 -1
  137. package/dist/services/interfaces.d.ts +0 -1
  138. package/dist/services/interfaces.js.map +1 -1
  139. package/dist/services/pnp-provenance.d.ts +0 -1
  140. package/dist/services/pnp-provenance.js.map +1 -1
  141. package/dist/services/pnp-standard-features.d.ts +0 -1
  142. package/dist/services/pnp-standard-features.js.map +1 -1
  143. package/dist/services/section-controller-types.d.ts +0 -1
  144. package/dist/services/section-controller-types.js.map +1 -1
  145. package/dist/services/tool-config-defaults.d.ts +0 -1
  146. package/dist/services/tool-config-defaults.js.map +1 -1
  147. package/dist/services/tool-config-validation.d.ts +0 -1
  148. package/dist/services/tool-config-validation.js.map +1 -1
  149. package/dist/services/tool-context.d.ts +0 -1
  150. package/dist/services/tool-context.js.map +1 -1
  151. package/dist/services/tool-instance-id.d.ts +0 -1
  152. package/dist/services/tool-instance-id.js.map +1 -1
  153. package/dist/services/tool-providers/DesmosToolProvider.d.ts +0 -1
  154. package/dist/services/tool-providers/DesmosToolProvider.js.map +1 -1
  155. package/dist/services/tool-providers/TTSToolProvider.d.ts +0 -1
  156. package/dist/services/tool-providers/TTSToolProvider.js.map +1 -1
  157. package/dist/services/tool-providers/ToolProviderApi.d.ts +0 -1
  158. package/dist/services/tool-providers/ToolProviderApi.js.map +1 -1
  159. package/dist/services/tool-providers/ToolProviderRegistry.d.ts +0 -1
  160. package/dist/services/tool-providers/ToolProviderRegistry.js.map +1 -1
  161. package/dist/services/tool-providers/index.d.ts +0 -1
  162. package/dist/services/tool-providers/index.js.map +1 -1
  163. package/dist/services/toolbar-items.d.ts +0 -1
  164. package/dist/services/toolbar-items.js.map +1 -1
  165. package/dist/services/tools-config-normalizer.d.ts +0 -1
  166. package/dist/services/tools-config-normalizer.js.map +1 -1
  167. package/dist/services/tts/browser-provider.d.ts +0 -1
  168. package/dist/services/tts/browser-provider.js.map +1 -1
  169. package/dist/services/tts/text-processing.d.ts +0 -1
  170. package/dist/services/tts/text-processing.js.map +1 -1
  171. package/dist/services/tts/text-segmentation.d.ts +0 -1
  172. package/dist/services/tts/text-segmentation.js.map +1 -1
  173. package/dist/services/tts/visual-line-ranges.d.ts +0 -1
  174. package/dist/services/tts/visual-line-ranges.js.map +1 -1
  175. package/dist/services/tts-control-events.d.ts +0 -1
  176. package/dist/services/tts-control-events.js.map +1 -1
  177. package/dist/services/tts-runtime-config.d.ts +0 -1
  178. package/dist/services/tts-runtime-config.js.map +1 -1
  179. package/dist/tools/calculators/desmos-provider.d.ts +0 -1
  180. package/dist/tools/calculators/desmos-provider.js.map +1 -1
  181. package/dist/tools/client.d.ts +0 -1
  182. package/dist/tools/client.js.map +1 -1
  183. package/dist/tools/default-tool-module-loaders.d.ts +0 -1
  184. package/dist/tools/default-tool-module-loaders.js.map +1 -1
  185. package/dist/tools/index.d.ts +0 -1
  186. package/dist/tools/index.js.map +1 -1
  187. package/dist/tools/library-loader.d.ts +0 -1
  188. package/dist/tools/library-loader.js.map +1 -1
  189. package/dist/tools/registrations/accessibility-tools.d.ts +0 -1
  190. package/dist/tools/registrations/accessibility-tools.js.map +1 -1
  191. package/dist/tools/registrations/calculator.d.ts +0 -1
  192. package/dist/tools/registrations/calculator.js.map +1 -1
  193. package/dist/tools/registrations/interaction-tools.d.ts +0 -1
  194. package/dist/tools/registrations/interaction-tools.js.map +1 -1
  195. package/dist/tools/registrations/measurement-tools.d.ts +0 -1
  196. package/dist/tools/registrations/measurement-tools.js.map +1 -1
  197. package/dist/tools/registrations/subject-specific-tools.d.ts +0 -1
  198. package/dist/tools/registrations/subject-specific-tools.js.map +1 -1
  199. package/dist/tools/registrations/toolbar-registration-helpers.d.ts +0 -1
  200. package/dist/tools/registrations/toolbar-registration-helpers.js.map +1 -1
  201. package/dist/tools/registrations/tts.d.ts +0 -1
  202. package/dist/tools/registrations/tts.js.map +1 -1
  203. package/dist/tools/response-discovery.d.ts +0 -1
  204. package/dist/tools/response-discovery.js.map +1 -1
  205. package/dist/tools/tool-tag-map.d.ts +0 -1
  206. package/dist/tools/tool-tag-map.js.map +1 -1
  207. package/dist/tools/types.d.ts +0 -1
  208. package/dist/tools/types.js.map +1 -1
  209. package/dist/tools/variant-resolver.d.ts +0 -1
  210. package/dist/tools/variant-resolver.js.map +1 -1
  211. package/dist/utils/logger.d.ts +0 -1
  212. package/dist/utils/logger.js.map +1 -1
  213. package/package.json +7 -7
  214. package/dist/attempt/AssessmentSession.d.ts.map +0 -1
  215. package/dist/attempt/TestSession.d.ts.map +0 -1
  216. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts.map +0 -1
  217. package/dist/components/item-toolbar-element.d.ts.map +0 -1
  218. package/dist/components/pie-assessment-toolkit-element.d.ts.map +0 -1
  219. package/dist/components/section-toolbar-element.d.ts.map +0 -1
  220. package/dist/context/assessment-toolkit-context.d.ts.map +0 -1
  221. package/dist/context/runtime-context-consumer.d.ts.map +0 -1
  222. package/dist/index.d.ts.map +0 -1
  223. package/dist/item-loader.d.ts.map +0 -1
  224. package/dist/policy/core/PolicySource.d.ts.map +0 -1
  225. package/dist/policy/core/ToolPolicyEngine.d.ts.map +0 -1
  226. package/dist/policy/core/compose-decision.d.ts.map +0 -1
  227. package/dist/policy/core/decision-types.d.ts.map +0 -1
  228. package/dist/policy/core/engine-context.d.ts.map +0 -1
  229. package/dist/policy/core/pnp-policy-inputs.d.ts.map +0 -1
  230. package/dist/policy/core/policy-source-tag.d.ts.map +0 -1
  231. package/dist/policy/core/provenance.d.ts.map +0 -1
  232. package/dist/policy/engine.d.ts.map +0 -1
  233. package/dist/policy/internal.d.ts.map +0 -1
  234. package/dist/policy/sources/PnpPolicySource.d.ts.map +0 -1
  235. package/dist/runtime/RuntimeRegistry.d.ts.map +0 -1
  236. package/dist/runtime/SectionRuntimeEngine.d.ts.map +0 -1
  237. package/dist/runtime/adapter/SectionEngineAdapter.d.ts.map +0 -1
  238. package/dist/runtime/adapter/coordinator-bridge.d.ts.map +0 -1
  239. package/dist/runtime/adapter/dom-event-bridge.d.ts.map +0 -1
  240. package/dist/runtime/adapter/framework-error-bridge.d.ts.map +0 -1
  241. package/dist/runtime/adapter/instrumentation-bridge.d.ts.map +0 -1
  242. package/dist/runtime/adapter/subscriber-fanout.d.ts.map +0 -1
  243. package/dist/runtime/core/SectionEngineCore.d.ts.map +0 -1
  244. package/dist/runtime/core/cohort.d.ts.map +0 -1
  245. package/dist/runtime/core/engine-input.d.ts.map +0 -1
  246. package/dist/runtime/core/engine-output.d.ts.map +0 -1
  247. package/dist/runtime/core/engine-readiness.d.ts.map +0 -1
  248. package/dist/runtime/core/engine-resolver.d.ts.map +0 -1
  249. package/dist/runtime/core/engine-stage-derivation.d.ts.map +0 -1
  250. package/dist/runtime/core/engine-state.d.ts.map +0 -1
  251. package/dist/runtime/core/engine-transition.d.ts.map +0 -1
  252. package/dist/runtime/engine-context.d.ts.map +0 -1
  253. package/dist/runtime/engine.d.ts.map +0 -1
  254. package/dist/runtime/internal.d.ts.map +0 -1
  255. package/dist/runtime/registration-events.d.ts.map +0 -1
  256. package/dist/runtime/runtime-id.d.ts.map +0 -1
  257. package/dist/runtime/section-runtime-engine-host-context.d.ts.map +0 -1
  258. package/dist/runtime/session-event-emitter-policy.d.ts.map +0 -1
  259. package/dist/runtime/stage-emit-gate.d.ts.map +0 -1
  260. package/dist/runtime/tool-host-contract.d.ts.map +0 -1
  261. package/dist/services/AccessibilityCatalogResolver.d.ts.map +0 -1
  262. package/dist/services/ContextVariableStore.d.ts.map +0 -1
  263. package/dist/services/ElementToolStateStore.d.ts.map +0 -1
  264. package/dist/services/HighlightCoordinator.d.ts.map +0 -1
  265. package/dist/services/I18nService.d.ts.map +0 -1
  266. package/dist/services/PNPToolResolver.d.ts.map +0 -1
  267. package/dist/services/RangeSerializer.d.ts.map +0 -1
  268. package/dist/services/SSMLExtractor.d.ts.map +0 -1
  269. package/dist/services/TTSService.d.ts.map +0 -1
  270. package/dist/services/ThemeProvider.d.ts.map +0 -1
  271. package/dist/services/ToolConfigResolver.d.ts.map +0 -1
  272. package/dist/services/ToolCoordinator.d.ts.map +0 -1
  273. package/dist/services/ToolRegistry.d.ts.map +0 -1
  274. package/dist/services/ToolkitCoordinator.d.ts.map +0 -1
  275. package/dist/services/create-tools-config.d.ts.map +0 -1
  276. package/dist/services/createDefaultToolRegistry.d.ts.map +0 -1
  277. package/dist/services/defaultPersonalNeedsProfile.d.ts.map +0 -1
  278. package/dist/services/framework-error-bus.d.ts.map +0 -1
  279. package/dist/services/framework-error.d.ts.map +0 -1
  280. package/dist/services/interfaces.d.ts.map +0 -1
  281. package/dist/services/pnp-provenance.d.ts.map +0 -1
  282. package/dist/services/pnp-standard-features.d.ts.map +0 -1
  283. package/dist/services/section-controller-types.d.ts.map +0 -1
  284. package/dist/services/tool-config-defaults.d.ts.map +0 -1
  285. package/dist/services/tool-config-validation.d.ts.map +0 -1
  286. package/dist/services/tool-context.d.ts.map +0 -1
  287. package/dist/services/tool-instance-id.d.ts.map +0 -1
  288. package/dist/services/tool-providers/DesmosToolProvider.d.ts.map +0 -1
  289. package/dist/services/tool-providers/TTSToolProvider.d.ts.map +0 -1
  290. package/dist/services/tool-providers/ToolProviderApi.d.ts.map +0 -1
  291. package/dist/services/tool-providers/ToolProviderRegistry.d.ts.map +0 -1
  292. package/dist/services/tool-providers/index.d.ts.map +0 -1
  293. package/dist/services/toolbar-items.d.ts.map +0 -1
  294. package/dist/services/tools-config-normalizer.d.ts.map +0 -1
  295. package/dist/services/tts/browser-provider.d.ts.map +0 -1
  296. package/dist/services/tts/text-processing.d.ts.map +0 -1
  297. package/dist/services/tts/text-segmentation.d.ts.map +0 -1
  298. package/dist/services/tts/visual-line-ranges.d.ts.map +0 -1
  299. package/dist/services/tts-control-events.d.ts.map +0 -1
  300. package/dist/services/tts-runtime-config.d.ts.map +0 -1
  301. package/dist/tools/calculators/desmos-provider.d.ts.map +0 -1
  302. package/dist/tools/client.d.ts.map +0 -1
  303. package/dist/tools/default-tool-module-loaders.d.ts.map +0 -1
  304. package/dist/tools/index.d.ts.map +0 -1
  305. package/dist/tools/library-loader.d.ts.map +0 -1
  306. package/dist/tools/registrations/accessibility-tools.d.ts.map +0 -1
  307. package/dist/tools/registrations/calculator.d.ts.map +0 -1
  308. package/dist/tools/registrations/interaction-tools.d.ts.map +0 -1
  309. package/dist/tools/registrations/measurement-tools.d.ts.map +0 -1
  310. package/dist/tools/registrations/subject-specific-tools.d.ts.map +0 -1
  311. package/dist/tools/registrations/toolbar-registration-helpers.d.ts.map +0 -1
  312. package/dist/tools/registrations/tts.d.ts.map +0 -1
  313. package/dist/tools/response-discovery.d.ts.map +0 -1
  314. package/dist/tools/tool-tag-map.d.ts.map +0 -1
  315. package/dist/tools/types.d.ts.map +0 -1
  316. package/dist/tools/variant-resolver.d.ts.map +0 -1
  317. package/dist/utils/logger.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimeRegistry.js","sourceRoot":"","sources":["../../src/runtime/RuntimeRegistry.ts"],"names":[],"mappings":"AASA,SAAS,oBAAoB,CAAC,CAAc,EAAE,CAAc;IAC3D,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,MAAM,QAAQ,GAAG,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,QAAQ,GAAG,IAAI,CAAC,2BAA2B;QAAE,OAAO,CAAC,CAAC;IAC1D,IAAI,QAAQ,GAAG,IAAI,CAAC,2BAA2B;QAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,CAAC;AACV,CAAC;AAED,MAAM,OAAO,eAAe;IACV,eAAe,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE3E,QAAQ,CAAC,MAAiC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1D,MAAM,UAAU,GAAoB;YACnC,GAAG,MAAM;YACT,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;SACnB,CAAC;Q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AAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAC/D,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CACvC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,iBAAiB;QAChB,MAAM,GAAG,GAA2B,EAAE,CAAC;QACvC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,KAAK,CAAC,MAAM;gBAAE,SAAS;YAC5B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC,MAAM,CAAC;QAC3D,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import type {\n\tRuntimeRegistrationDetail,\n\tRuntimeRegistrationKind,\n} from \"./registration-events.js\";\n\nexport interface RegisteredShell extends RuntimeRegistrationDetail {\n\tsortKey: number;\n}\n\nfunction compareDocumentOrder(a: HTMLElement, b: HTMLElement): number {\n\tif (a === b) return 0;\n\tconst position = a.compareDocumentPosition(b);\n\tif (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;\n\tif (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;\n\treturn 0;\n}\n\nexport class RuntimeRegistry {\n\tprivate readonly shellsByElement = new Map<HTMLElement, RegisteredShell>();\n\n\tregister(detail: RuntimeRegistrationDetail): boolean {\n\t\tconst existing = this.shellsByElement.get(detail.element);\n\t\tconst nextRecord: RegisteredShell = {\n\t\t\t...detail,\n\t\t\tsortKey: Date.now(),\n\t\t};\n\n\t\t// Idempotent no-op for identical registrations.\n\t\tif (\n\t\t\texisting &&\n\t\t\texisting.kind === nextRecord.kind &&\n\t\t\texisting.itemId === nextRecord.itemId &&\n\t\t\texisting.canonicalItemId === nextRecord.canonicalItemId\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.shellsByElement.set(detail.element, nextRecord);\n\t\treturn true;\n\t}\n\n\tunregister(element: HTMLElement): boolean {\n\t\treturn this.shellsByElement.delete(element);\n\t}\n\n\tgetOrderedShells(kind?: RuntimeRegistrationKind): RegisteredShell[] {\n\t\tconst records = Array.from(this.shellsByElement.values()).filter(\n\t\t\t(entry) => !kind || entry.kind === kind,\n\t\t);\n\t\trecords.sort((a, b) => compareDocumentOrder(a.element, b.element));\n\t\treturn records;\n\t}\n\n\tgetCanonicalIdMap(): Record<string, string> {\n\t\tconst map: Record<string, string> = {};\n\t\tfor (const entry of this.getOrderedShells(\"item\")) {\n\t\t\tif (!entry.itemId) continue;\n\t\t\tmap[entry.itemId] = entry.canonicalItemId || entry.itemId;\n\t\t}\n\t\treturn map;\n\t}\n\n\tclear(): void {\n\t\tthis.shellsByElement.clear();\n\t}\n}\n"]}
@@ -294,4 +294,3 @@ export declare class SectionRuntimeEngine {
294
294
  dispose(): Promise<void>;
295
295
  }
296
296
  export {};
297
- //# sourceMappingURL=SectionRuntimeEngine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SectionRuntimeEngine.js","sourceRoot":"","sources":["../../src/runtime/SectionRuntimeEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAQH,OAAO,EACN,oBAAoB,GAEpB,MAAM,mCAAmC,CAAC;AAK3C,OAAO,EACN,gCAAgC,GAGhC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,wBAAwB,GAEx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,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC;gBAC/C,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;aACzB,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,8DAA8D;QAC9D,4DAA4D;QAC5D,4DAA4D;QAC5D,uBAAuB;QACvB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;IACF,CAAC;CACD;AAED,MAAM,WAAW,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC","sourcesContent":["/**\n * Section runtime engine — public facade (M7 — Variant C, layered).\n *\n * The facade is the narrow, stable entry point hosts use to mount,\n * drive, and dispose a section runtime. It composes three layers\n * introduced in earlier M7 PRs:\n *\n * - the **registry** (`RuntimeRegistry`) — registered item/passage\n * shells in document order, used for canonical-id lookup;\n * - the **adapter** (`SectionEngineAdapter`) — single I/O seam over\n * the pure FSM core, fanning outputs to the DOM, framework-error\n * bus, legacy events, instrumentation hook, and host subscribers;\n * - the **resolver** (`resolveSectionEngineRuntimeState`) — the\n * toolkit-side resolution helper that produces the effective\n * runtime + tools snapshot a host feeds to the FSM core.\n *\n * **Two callsite generations.** During the M7 migration window the\n * facade carries two surface generations side-by-side:\n *\n * 1. The **engine-side** surface (`attachHost`, `dispatchInput`,\n * `subscribe`, `getState`, `getEffectiveRuntime`,\n * `setInstrumentationHook`). This is what the kernel and the\n * `pie-assessment-toolkit` CE will switch onto in M7 PR 5 and\n * PR 6. Construction is lazy: `attachHost(...)` builds the\n * adapter on first call, with the supplied host element,\n * framework-error bus, and (optional) coordinator. After\n * construction, host re-attachments (e.g. cohort change with a\n * new layout shell) update the adapter's host element via\n * `setHost(...)`.\n *\n * 2. The **legacy controller-side** surface (`initialize`,\n * `register`, `unregister`, `handleContent*`, `updateItemSession`,\n * `navigateToItem`, `persist`, `hydrate`, `dispose`). The\n * `PieAssessmentToolkit.svelte` CE still drives the seed via this\n * surface in PR 3 — observable behavior is identical to pre-PR 3.\n * PR 6 deletes the toolkit's reliance on this surface; PR 7\n * removes the methods that the engine FSM has fully absorbed.\n *\n * The two surfaces share `RuntimeRegistry` (the only piece both\n * generations consult) and the resolved `SectionControllerHandle` the\n * legacy generation holds inline. The adapter holds its own\n * `coordinator-bridge` independently — the legacy `initialize(...)` and\n * the engine-side `dispatchInput({ kind: \"initialize\" })` do **not**\n * fight over the coordinator because PR 3 only activates one of them\n * per host (legacy from the toolkit CE, engine-side from the PR 5+\n * tests and the kernel/toolkit switches).\n *\n * **Why the legacy surface stays.** The plan's PR-3 acceptance criterion\n * is \"existing toolkit tests still pass; no section-player or toolkit\n * CE code changes yet\" — so PR 3 cannot delete the controller-side\n * methods. PR 6 (toolkit switch) and PR 7 (rip-out) will remove them\n * once the engine surface is the only consumer.\n */\n\nimport type { ToolkitCoordinator } from \"../services/ToolkitCoordinator.js\";\nimport type { FrameworkErrorReporter } from \"../services/framework-error-bus.js\";\nimport type {\n\tSectionControllerEvent,\n\tSectionControllerHandle,\n} from \"../services/section-controller-types.js\";\nimport {\n\tSectionEngineAdapter,\n\ttype SectionEngineAdapterOptions,\n} from \"./adapter/SectionEngineAdapter.js\";\nimport type { InstrumentationHook } from \"./adapter/instrumentation-bridge.js\";\nimport type { EngineOutputListener } from \"./adapter/subscriber-fanout.js\";\nimport type { SectionEngineInput } from \"./core/engine-input.js\";\nimport type { SectionEngineOutput } from \"./core/engine-output.js\";\nimport {\n\tresolveSectionEngineRuntimeState,\n\ttype EffectiveRuntime,\n\ttype RuntimeInputs,\n} from \"./core/engine-resolver.js\";\nimport {\n\tcreateInitialEngineState,\n\ttype SectionEngineState,\n} from \"./core/engine-state.js\";\nimport type { RuntimeRegistrationDetail } from \"./registration-events.js\";\nimport { RuntimeRegistry } from \"./RuntimeRegistry.js\";\nimport { createRuntimeId } from \"./runtime-id.js\";\n\n/**\n * Structural view of the resolved section controller, widened with the\n * extra methods the toolkit's runtime CE calls directly. Optional so\n * stub controllers used in tests do not need every entry point.\n */\ninterface RuntimeController extends SectionControllerHandle {\n\tgetCompositionModel?: () => unknown;\n\tgetCanonicalItemId?: (itemId: string) => string;\n\thandleContentLoaded?: (args: {\n\t\titemId: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t\tdetail?: unknown;\n\t\ttimestamp?: number;\n\t}) => void;\n\thandleContentRegistered?: (args: {\n\t\titemId: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t}) => void;\n\thandleContentUnregistered?: (args: {\n\t\titemId: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t}) => void;\n\thandleItemPlayerError?: (args: {\n\t\titemId: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t\terror: unknown;\n\t\ttimestamp?: number;\n\t}) => void;\n\treportSectionError?: (args: {\n\t\tsource: \"item-player\" | \"section-runtime\" | \"toolkit\" | \"controller\";\n\t\terror: unknown;\n\t\titemId?: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t\ttimestamp?: number;\n\t}) => void;\n\tupdateItemSession?: (\n\t\titemId: string,\n\t\tsessionDetail: unknown,\n\t) => { eventDetail?: unknown } | null;\n\tsubscribe?: (listener: (event: SectionControllerEvent) => void) => () => void;\n\tnavigateToItem?: (index: number) => unknown;\n}\n\n/**\n * Legacy initialize args. Pre-PR 6 callers (the toolkit CE) drive the\n * coordinator + section controller through this method. PR 6 will\n * delete this in favor of the engine-side `attachHost` +\n * `dispatchInput({ kind: \"initialize\" })` flow.\n */\ninterface EngineInitArgs {\n\tcoordinator: ToolkitCoordinator;\n\tsection: unknown;\n\tsectionId: string;\n\tassessmentId: string;\n\tview: string;\n\tattemptId?: string;\n\tcreateDefaultController: () => Promise<RuntimeController> | RuntimeController;\n\tonCompositionChanged?: (composition: unknown) => void;\n}\n\n/**\n * Engine-side `attachHost` args. The host element, framework-error bus,\n * and `sourceCe` together let the adapter dispatch DOM events and bus\n * fan-outs identically to the legacy kernel emit chain.\n */\nexport interface SectionRuntimeEngineHostArgs {\n\thost: EventTarget;\n\tsourceCe: string;\n\tframeworkErrorBus: FrameworkErrorReporter;\n\tcoordinator?: SectionEngineAdapterOptions[\"coordinator\"];\n\tinstrumentationHook?: InstrumentationHook;\n\tnow?: () => string;\n}\n\nexport class SectionRuntimeEngine {\n\tprivate readonly registry = new RuntimeRegistry();\n\tprivate readonly runtimeId = createRuntimeId(\"section-engine\");\n\n\t// Engine-side state (PR 3+).\n\tprivate adapter: SectionEngineAdapter | null = null;\n\n\t// Legacy controller-side state (until PR 6).\n\tprivate controller: RuntimeController | null = null;\n\tprivate coordinator: ToolkitCoordinator | null = null;\n\tprivate sectionId = \"\";\n\tprivate attemptId: string | undefined;\n\tprivate unsubscribeController: (() => void) | null = null;\n\tprivate activeInitToken = 0;\n\n\t/**\n\t * Tracks which `(canonicalItemId, contentKind)` pairs have already\n\t * fired `handleContentLoaded` on this engine. Mirrored alongside\n\t * `RuntimeRegistry`'s registered set so a cohort handoff can\n\t * replay the persistent shells' loaded state into the new\n\t * controller — see `replayRegisteredShellsIntoController` and the\n\t * PIE-512 Phase B regression test.\n\t *\n\t * Cleared in lockstep with `handleContentUnregistered` and on\n\t * `dispose`. Not exposed publicly: the registry alone is the\n\t * external surface; the loaded set exists only to seed cohort B's\n\t * controller with the live state cohort A's shells produced.\n\t */\n\tprivate readonly loadedRenderableKeys = new Set<string>();\n\n\t// ============================================================\n\t// Engine-side surface (PR 3+; driven by the kernel from PR 5,\n\t// by the toolkit CE from PR 6, and by the facade smoke test today).\n\t// ============================================================\n\n\t/**\n\t * Attach the host element + framework-error bus + sourceCe so the\n\t * adapter can dispatch DOM events and bus errors. Required before\n\t * `dispatchInput` / `subscribe` produce observable effects.\n\t *\n\t * Constructs the adapter on the first call. Subsequent calls keep\n\t * the adapter and update its host element / instrumentation hook\n\t * (used by layout-shell rollovers and instrumentation reconfig).\n\t */\n\tattachHost(args: SectionRuntimeEngineHostArgs): void {\n\t\tif (this.adapter) {\n\t\t\tthis.adapter.setHost(args.host);\n\t\t\tif (args.instrumentationHook !== undefined) {\n\t\t\t\tthis.adapter.setInstrumentationHook(args.instrumentationHook);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis.adapter = new SectionEngineAdapter({\n\t\t\thost: args.host,\n\t\t\truntimeId: this.runtimeId,\n\t\t\tsourceCe: args.sourceCe,\n\t\t\tframeworkErrorBus: args.frameworkErrorBus,\n\t\t\tcoordinator: args.coordinator,\n\t\t\tinstrumentationHook: args.instrumentationHook,\n\t\t\tnow: args.now,\n\t\t});\n\t}\n\n\t/**\n\t * Forward a host-constructed input to the FSM core via the adapter.\n\t * Returns the outputs the transition produced (subscribers and the\n\t * DOM/legacy/framework-error/instrumentation bridges have already\n\t * received them).\n\t *\n\t * No-op (returns `[]`) before `attachHost(...)` so callers that\n\t * dispatch optimistically during teardown do not throw.\n\t */\n\tdispatchInput(input: SectionEngineInput): readonly SectionEngineOutput[] {\n\t\treturn this.adapter?.dispatchInput(input) ?? [];\n\t}\n\n\t/**\n\t * Subscribe to batched engine outputs (one batch per\n\t * `dispatchInput`). Returns an idempotent disposer. Pre-`attachHost`\n\t * subscriptions return a no-op disposer so callers can wire\n\t * subscriptions early without lifecycle-ordering hazards.\n\t */\n\tsubscribe(listener: EngineOutputListener): () => void {\n\t\treturn this.adapter?.subscribe(listener) ?? noopDispose;\n\t}\n\n\t/**\n\t * Read-only snapshot of the FSM state. Returns the initial idle\n\t * state before `attachHost` so callers can probe state without\n\t * special-casing the pre-attach phase.\n\t */\n\tgetState(): Readonly<SectionEngineState> {\n\t\treturn this.adapter?.getState() ?? createInitialEngineState();\n\t}\n\n\t/**\n\t * Resolve the effective runtime + tools snapshot for the given\n\t * two-tier inputs. This is a pure function over the resolver — it\n\t * does not depend on adapter state — so callers can use it both\n\t * pre- and post-`attachHost`. The kernel uses it to seed\n\t * `dispatchInput({ kind: \"initialize\", effectiveRuntime, ... })`.\n\t */\n\tgetEffectiveRuntime<P>(\n\t\targs: RuntimeInputs,\n\t\tdeps: {\n\t\t\tresolvePlayerRuntime: (resolverArgs: {\n\t\t\t\teffectiveRuntime: Record<string, unknown>;\n\t\t\t\tplayerType: string;\n\t\t\t\tenv: Record<string, unknown> | null;\n\t\t\t}) => P;\n\t\t},\n\t): EffectiveRuntime {\n\t\treturn resolveSectionEngineRuntimeState(args, deps).effectiveRuntime;\n\t}\n\n\t/**\n\t * Update the adapter's instrumentation hook. No-op pre-attach.\n\t * Hosts that always want a hook should pass it via `attachHost`.\n\t */\n\tsetInstrumentationHook(hook: InstrumentationHook | undefined): void {\n\t\tthis.adapter?.setInstrumentationHook(hook);\n\t}\n\n\t/**\n\t * Stable per-engine runtime id used to scope DOM-event details and\n\t * registry telemetry. Exposed so tests and instrumentation can pin\n\t * the value the bridges emit.\n\t */\n\tgetRuntimeId(): string {\n\t\treturn this.runtimeId;\n\t}\n\n\t// ============================================================\n\t// Legacy controller-side surface (kept until PR 6; behavior\n\t// identical to pre-PR 3).\n\t// ============================================================\n\n\tasync initialize(args: EngineInitArgs): Promise<void> {\n\t\tthis.activeInitToken += 1;\n\t\tconst token = this.activeInitToken;\n\t\tthis.coordinator = args.coordinator;\n\t\tthis.sectionId = args.sectionId;\n\t\tthis.attemptId = args.attemptId;\n\n\t\tconst resolved = (await args.coordinator.getOrCreateSectionController({\n\t\t\tsectionId: args.sectionId,\n\t\t\tattemptId: args.attemptId,\n\t\t\tinput: {\n\t\t\t\tsection: args.section,\n\t\t\t\tsectionId: args.sectionId,\n\t\t\t\tassessmentId: args.assessmentId,\n\t\t\t\tview: args.view,\n\t\t\t},\n\t\t\tupdateExisting: true,\n\t\t\tcreateDefaultController: args.createDefaultController,\n\t\t})) as RuntimeController;\n\n\t\tif (token !== this.activeInitToken) return;\n\t\tthis.unsubscribeController?.();\n\t\tthis.controller = resolved;\n\t\t// PIE-512 Phase C: always re-feed the registry's currently\n\t\t// registered shells (and their loaded state) into the resolved\n\t\t// controller. We do NOT gate on `resolved !== previousController`\n\t\t// any more.\n\t\t//\n\t\t// Why the gate had to go:\n\t\t// - Cohort flip resolving to a fresh controller — replay seeds\n\t\t// the new controller, which is the original Phase B fix.\n\t\t// - Same-cohort `updateInput` resolving to the existing\n\t\t// controller — the coordinator's\n\t\t// `resolveExistingSectionController` calls\n\t\t// `existingController.updateInput(input)` (engine always\n\t\t// passes `updateExisting: true`), and pre-Phase-C\n\t\t// `SectionController.initialize` wiped lifecycle tracking\n\t\t// unconditionally. A subscriber attaching between the wipe\n\t\t// and the next live event saw an empty\n\t\t// `loadedRenderables` snapshot.\n\t\t//\n\t\t// Phase C makes this re-feed safe by combining (a) the\n\t\t// section-identity gate around `resetLifecycleTracking()` in\n\t\t// `SectionController.initialize` (so same-cohort `updateInput`\n\t\t// preserves tracking) with (b) idempotent\n\t\t// `handleContentRegistered` / `handleContentLoaded` on the\n\t\t// controller (so re-feeding the same registry entries is a\n\t\t// no-op if the controller already knows about them, but\n\t\t// re-seeds the controller in the post-`updateInput`-wipe case\n\t\t// that pre-Phase-C used to encounter).\n\t\tthis.replayRegisteredShellsIntoController(resolved);\n\t\targs.onCompositionChanged?.(resolved.getCompositionModel?.());\n\t\tthis.unsubscribeController =\n\t\t\tresolved.subscribe?.(() => {\n\t\t\t\targs.onCompositionChanged?.(resolved.getCompositionModel?.());\n\t\t\t}) || null;\n\t}\n\n\t/**\n\t * Re-feed the engine's `RuntimeRegistry` and loaded-set into the\n\t * resolved controller. Call site: `initialize(...)` — runs on\n\t * EVERY initialize, both cohort-flip-resolves-fresh-controller\n\t * and same-cohort-resolves-existing-controller cases. Phase C\n\t * dropped the `resolved !== previousController` gate; see the\n\t * comment at the call site for why.\n\t *\n\t * Two-pass order — register every shell in document order, then\n\t * issue `handleContentLoaded` for each shell whose load already\n\t * fired on this engine. The two-pass shape prevents\n\t * `evaluateSectionLoadingState` from flapping\n\t * `section-loading-complete` `false→true→false→…` while replay is\n\t * mid-walk: any subscriber wired before the engine's own\n\t * `controller.subscribe` (no such caller today, but cheap defense\n\t * for future wiring) sees one clean `false→true` transition.\n\t *\n\t * Idempotent on the controller side — Phase C makes\n\t * `SectionController.handleContentRegistered` and\n\t * `handleContentLoaded` early-return on duplicates so re-feeding\n\t * the same shells into a controller that already tracks them is\n\t * a true no-op (no spurious re-emits, no re-evaluation of\n\t * `section-loading-complete`). At the call site no listener is\n\t * attached during the replay window, so `emitChange` side effects\n\t * fire into a void on this pass anyway, but the controller-side\n\t * idempotence is what makes the replay safe to run on every\n\t * initialize regardless of whether the controller is fresh.\n\t */\n\tprivate replayRegisteredShellsIntoController(\n\t\tcontroller: RuntimeController,\n\t): void {\n\t\tif (!controller.handleContentRegistered) return;\n\t\tconst shells = this.registry.getOrderedShells();\n\t\tif (shells.length === 0) return;\n\t\tfor (const shell of shells) {\n\t\t\tconst canonicalItemId = shell.canonicalItemId || shell.itemId;\n\t\t\tcontroller.handleContentRegistered({\n\t\t\t\titemId: shell.itemId,\n\t\t\t\tcanonicalItemId,\n\t\t\t\tcontentKind: shell.contentKind || shell.kind,\n\t\t\t});\n\t\t}\n\t\tconst now = Date.now();\n\t\tfor (const shell of shells) {\n\t\t\tconst canonicalItemId = shell.canonicalItemId || shell.itemId;\n\t\t\tconst key = this.getLoadedKey(canonicalItemId, shell.contentKind);\n\t\t\tif (this.loadedRenderableKeys.has(key)) {\n\t\t\t\tcontroller.handleContentLoaded?.({\n\t\t\t\t\titemId: shell.itemId,\n\t\t\t\t\tcanonicalItemId,\n\t\t\t\t\tcontentKind: shell.contentKind || shell.kind,\n\t\t\t\t\ttimestamp: now,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stable key for the engine's `loadedRenderableKeys` set. Mirrors\n\t * the `(canonicalItemId, contentKind)` shape `SectionController`\n\t * uses internally (see `getRenderableKey`); we only need\n\t * consistent add/check semantics on this side, not byte-identical\n\t * normalization with the controller.\n\t */\n\tprivate getLoadedKey(\n\t\tcanonicalItemId: string,\n\t\tcontentKind: string | undefined,\n\t): string {\n\t\treturn `${contentKind ?? \"\"}:${canonicalItemId}`;\n\t}\n\n\tregister(detail: RuntimeRegistrationDetail): boolean {\n\t\treturn this.registry.register(detail);\n\t}\n\n\tunregister(element: HTMLElement): boolean {\n\t\treturn this.registry.unregister(element);\n\t}\n\n\tgetCompositionModel(): unknown {\n\t\treturn this.controller?.getCompositionModel?.() ?? null;\n\t}\n\n\tgetCanonicalItemId(itemId: string): string {\n\t\tconst map = this.registry.getCanonicalIdMap();\n\t\treturn map[itemId] || this.controller?.getCanonicalItemId?.(itemId) || itemId;\n\t}\n\n\thandleContentRegistered(detail: RuntimeRegistrationDetail): void {\n\t\tthis.controller?.handleContentRegistered?.({\n\t\t\titemId: detail.itemId,\n\t\t\tcanonicalItemId: detail.canonicalItemId || detail.itemId,\n\t\t\tcontentKind: detail.contentKind || detail.kind,\n\t\t});\n\t}\n\n\thandleContentUnregistered(detail: RuntimeRegistrationDetail): void {\n\t\tconst canonicalItemId = detail.canonicalItemId || detail.itemId;\n\t\t// Key the load-set delete with the same `contentKind`-only\n\t\t// shape that `handleContentLoaded` and\n\t\t// `replayRegisteredShellsIntoController` use, so add/check/\n\t\t// delete keys round-trip identically. The `|| detail.kind`\n\t\t// fallback is preserved for the controller-forwarded payload\n\t\t// because the controller normalizes via `toSectionContentKind`\n\t\t// and the legacy `kind` field is still meaningful there.\n\t\tthis.loadedRenderableKeys.delete(\n\t\t\tthis.getLoadedKey(canonicalItemId, detail.contentKind),\n\t\t);\n\t\tthis.controller?.handleContentUnregistered?.({\n\t\t\titemId: detail.itemId,\n\t\t\tcanonicalItemId,\n\t\t\tcontentKind: detail.contentKind || detail.kind,\n\t\t});\n\t}\n\n\thandleContentLoaded(args: {\n\t\titemId: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t\tdetail?: unknown;\n\t\ttimestamp?: number;\n\t}): void {\n\t\tconst canonicalItemId = args.canonicalItemId || args.itemId;\n\t\tthis.loadedRenderableKeys.add(\n\t\t\tthis.getLoadedKey(canonicalItemId, args.contentKind),\n\t\t);\n\t\tthis.controller?.handleContentLoaded?.(args);\n\t}\n\n\thandleItemPlayerError(args: {\n\t\titemId: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t\terror: unknown;\n\t\ttimestamp?: number;\n\t}): void {\n\t\tthis.controller?.handleItemPlayerError?.(args);\n\t}\n\n\treportSectionError(args: {\n\t\tsource: \"item-player\" | \"section-runtime\" | \"toolkit\" | \"controller\";\n\t\terror: unknown;\n\t\titemId?: string;\n\t\tcanonicalItemId?: string;\n\t\tcontentKind?: string;\n\t\ttimestamp?: number;\n\t}): void {\n\t\tthis.controller?.reportSectionError?.(args);\n\t}\n\n\tupdateItemSession(itemId: string, session: unknown): unknown {\n\t\tconst canonicalId = this.getCanonicalItemId(itemId);\n\t\treturn this.controller?.updateItemSession?.(canonicalId, session) ?? null;\n\t}\n\n\tnavigateToItem(index: number): unknown {\n\t\treturn this.controller?.navigateToItem?.(index) ?? null;\n\t}\n\n\tasync persist(): Promise<void> {\n\t\tawait this.controller?.persist?.();\n\t}\n\n\tasync hydrate(): Promise<void> {\n\t\tawait this.controller?.hydrate?.();\n\t}\n\n\tgetRegistry(): RuntimeRegistry {\n\t\treturn this.registry;\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tthis.activeInitToken += 1;\n\t\tthis.unsubscribeController?.();\n\t\tthis.unsubscribeController = null;\n\t\tif (this.coordinator && this.sectionId) {\n\t\t\tawait this.coordinator.disposeSectionController({\n\t\t\t\tsectionId: this.sectionId,\n\t\t\t\tattemptId: this.attemptId,\n\t\t\t});\n\t\t}\n\t\tthis.registry.clear();\n\t\tthis.loadedRenderableKeys.clear();\n\t\tthis.controller = null;\n\t\tthis.coordinator = null;\n\t\t// Tear down the engine-side adapter (if attached) last so any\n\t\t// `dispose` FSM input flows through the bridges before they\n\t\t// detach. Adapter disposal is idempotent and safe even when\n\t\t// nothing is attached.\n\t\tif (this.adapter) {\n\t\t\tconst adapter = this.adapter;\n\t\t\tthis.adapter = null;\n\t\t\tawait adapter.dispose();\n\t\t}\n\t}\n}\n\nconst noopDispose = (): void => {};\n"]}
@@ -141,4 +141,3 @@ export declare class SectionEngineAdapter {
141
141
  private routeOutputs;
142
142
  private routeOne;
143
143
  }
144
- //# sourceMappingURL=SectionEngineAdapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SectionEngineAdapter.js","sourceRoot":"","sources":["../../../src/runtime/adapter/SectionEngineAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAIjE,OAAO,EACN,uBAAuB,GAIvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,oBAAoB,GAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,0BAA0B,GAE1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,2BAA2B,GAG3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,sBAAsB,GAGtB,MAAM,wBAAwB,CAAC;AAqChC,MAAM,OAAO,oBAAoB;IACf,IAAI,CAAoB;IACxB,cAAc,CAAuB;IACrC,oBAAoB,CAA6B;IACjD,qBAAqB,CAA8B;IACnD,gBAAgB,CAAyB;IACzC,iBAAiB,CAAiC;IAClD,eAAe,CAAa;IACrC,QAAQ,GAAG,KAAK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CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAEO,QAAQ,CAAC,MAA2B;QAC3C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,cAAc,CAAC;YACpB,KAAK,kBAAkB;gBACtB,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACrC,MAAM;YACP,KAAK,iBAAiB;gBACrB,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACrC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAC3C,MAAM;YACP,OAAO,CAAC,CAAC,CAAC;gBACT,MAAM,UAAU,GAAU,MAAM,CAAC;gBACjC,KAAK,UAAU,CAAC;gBAChB,OAAO;YACR,CAAC;QACF,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/**\n * Section runtime engine adapter (M7 — Variant C, layered).\n *\n * The adapter is the single I/O seam between the pure FSM core\n * (`SectionEngineCore`) and the rest of the world (DOM, coordinator,\n * framework-error bus, host subscribers, instrumentation). It does\n * exactly two jobs:\n *\n * 1. Translate **host inputs** (from kernels, the toolkit CE, or\n * direct facade callers) into `SectionEngineInput`s and forward\n * them to the core via `core.dispatch(input)`.\n *\n * 2. Subscribe to the core's output stream and **route each output**\n * through the bridges in a deterministic order so the public DOM\n * surface, framework-error bus, instrumentation hook, and host\n * subscribers all see exactly the same fan-out with\n * byte-identical detail shapes.\n *\n * Output routing is a single exhaustive `switch` (`assertNever` on\n * the default branch) so adding a new `SectionEngineOutput` kind in\n * `engine-output.ts` is a compile error here until the adapter knows\n * what to do with it.\n *\n * **Routing order per output:**\n * - canonical DOM event (`pie-stage-change`, `pie-loading-complete`,\n * `framework-error`)\n * - framework-error bus (single fan-out for in-process subscribers)\n * - instrumentation hook\n * - public subscriber fan-out (batched, runs once per\n * `core.dispatch`)\n *\n * The deprecated `readiness-change` / `interaction-ready` / `ready`\n * DOM events and their `legacy-event-bridge.ts` were removed in the\n * broad architecture review compat sweep; the corresponding output\n * kinds are gone from `engine-output.ts`.\n *\n * **Layering constraint.** The adapter is plain TS. It must not\n * import `svelte` — the M7 implementation plan and\n * `scripts/check-engine-core-purity.mjs` enforce the core's purity;\n * the adapter follows the same constraint by convention so it stays\n * usable from non-Svelte hosts (Node tests, Storybook, or future\n * non-Svelte consumers). `bun run check:custom-elements` already\n * blocks `.svelte` imports in published `dist`; adding a Svelte\n * dependency here would also leak through that gate.\n */\n\nimport type { FrameworkErrorReporter } from \"../../services/framework-error-bus.js\";\nimport { SectionEngineCore } from \"../core/SectionEngineCore.js\";\nimport type { SectionEngineInput } from \"../core/engine-input.js\";\nimport type { SectionEngineOutput } from \"../core/engine-output.js\";\nimport type { SectionEngineState } from \"../core/engine-state.js\";\nimport {\n\tcreateCoordinatorBridge,\n\ttype CoordinatorBridgeHandle,\n\ttype CoordinatorPort,\n\ttype ResolveSectionControllerArgs,\n} from \"./coordinator-bridge.js\";\nimport {\n\tcreateDomEventBridge,\n\ttype DomEventBridgeHandle,\n} from \"./dom-event-bridge.js\";\nimport {\n\tcreateFrameworkErrorBridge,\n\ttype FrameworkErrorBridgeHandle,\n} from \"./framework-error-bridge.js\";\nimport {\n\tcreateInstrumentationBridge,\n\ttype InstrumentationBridgeHandle,\n\ttype InstrumentationHook,\n} from \"./instrumentation-bridge.js\";\nimport {\n\tcreateSubscriberFanout,\n\ttype EngineOutputListener,\n\ttype SubscriberFanoutHandle,\n} from \"./subscriber-fanout.js\";\n\nexport interface SectionEngineAdapterOptions {\n\t/** Element on which DOM events are dispatched. */\n\thost: EventTarget;\n\t/** Stable runtime id for this engine instance. */\n\truntimeId: string;\n\t/**\n\t * Tag name of the host CE without the `--version-<encoded>` suffix.\n\t */\n\tsourceCe: string;\n\t/**\n\t * Framework-error bus (write side). Shared with the toolkit CE so\n\t * subscribers via `coordinator.subscribeFrameworkErrors` see the\n\t * same fan-out.\n\t */\n\tframeworkErrorBus: FrameworkErrorReporter;\n\t/**\n\t * Optional toolkit coordinator. When supplied, the adapter wires\n\t * its framework-error subscription, controller resolution, and\n\t * disposal through the coordinator-bridge. Standalone callers (no\n\t * coordinator) can omit this and feed `framework-error` and\n\t * `section-controller-resolved` inputs directly.\n\t */\n\tcoordinator?: CoordinatorPort;\n\t/** Optional one-shot observability hook. */\n\tinstrumentationHook?: InstrumentationHook;\n\t/** Clock injection for the DOM bridge. Defaults to `Date.now()`. */\n\tnow?: () => string;\n\t/**\n\t * Optional pre-constructed core. Defaults to a fresh\n\t * `SectionEngineCore`. Tests pass a mocked core to assert dispatch\n\t * ordering; production callers use the default.\n\t */\n\tcore?: SectionEngineCore;\n}\n\nexport class SectionEngineAdapter {\n\tprivate readonly core: SectionEngineCore;\n\tprivate readonly domEventBridge: DomEventBridgeHandle;\n\tprivate readonly frameworkErrorBridge: FrameworkErrorBridgeHandle;\n\tprivate readonly instrumentationBridge: InstrumentationBridgeHandle;\n\tprivate readonly subscriberFanout: SubscriberFanoutHandle;\n\tprivate readonly coordinatorBridge: CoordinatorBridgeHandle | null;\n\tprivate readonly unsubscribeCore: () => void;\n\tprivate disposed = false;\n\n\tconstructor(options: SectionEngineAdapterOptions) {\n\t\tthis.core = options.core ?? new SectionEngineCore();\n\t\tthis.domEventBridge = createDomEventBridge({\n\t\t\thost: options.host,\n\t\t\truntimeId: options.runtimeId,\n\t\t\tsourceCe: options.sourceCe,\n\t\t\tnow: options.now,\n\t\t});\n\t\tthis.frameworkErrorBridge = createFrameworkErrorBridge({\n\t\t\tbus: options.frameworkErrorBus,\n\t\t});\n\t\tthis.instrumentationBridge = createInstrumentationBridge({\n\t\t\thook: options.instrumentationHook,\n\t\t});\n\t\tthis.subscriberFanout = createSubscriberFanout();\n\t\tthis.coordinatorBridge = options.coordinator\n\t\t\t? createCoordinatorBridge({\n\t\t\t\t\tcoordinator: options.coordinator,\n\t\t\t\t\tdispatchCoreInput: (input) => this.dispatchInput(input),\n\t\t\t\t})\n\t\t\t: null;\n\n\t\tthis.unsubscribeCore = this.core.subscribe((outputs) => {\n\t\t\tthis.routeOutputs(outputs);\n\t\t});\n\t}\n\n\t/**\n\t * Read-only snapshot of the FSM state. Mirrors\n\t * `SectionEngineCore.getState()`.\n\t */\n\tgetState(): Readonly<SectionEngineState> {\n\t\treturn this.core.getState();\n\t}\n\n\t/**\n\t * Forward a host-constructed input to the core. Returns the outputs\n\t * that resulted (the bridges have already received them).\n\t */\n\tdispatchInput(input: SectionEngineInput): readonly SectionEngineOutput[] {\n\t\tif (this.disposed) return [];\n\t\treturn this.core.dispatch(input);\n\t}\n\n\t/**\n\t * Subscribe to batched output streams, one batch per\n\t * `dispatchInput`.\n\t */\n\tsubscribe(listener: EngineOutputListener): () => void {\n\t\treturn this.subscriberFanout.subscribe(listener);\n\t}\n\n\t/**\n\t * Update the host element after construction (e.g. when the kernel\n\t * receives its host element via Svelte action / context).\n\t */\n\tsetHost(host: EventTarget): void {\n\t\tthis.domEventBridge.setHost(host);\n\t}\n\n\t/**\n\t * Update the instrumentation hook at runtime.\n\t */\n\tsetInstrumentationHook(hook: InstrumentationHook | undefined): void {\n\t\tthis.instrumentationBridge.setHook(hook);\n\t}\n\n\t/**\n\t * Resolve a section controller through the configured coordinator.\n\t *\n\t * Throws if the adapter was constructed without a coordinator.\n\t * Standalone callers should manually feed\n\t * `{ kind: \"section-controller-resolved\" }` after their own\n\t * controller resolution path completes.\n\t */\n\tresolveSectionController(args: ResolveSectionControllerArgs): Promise<void> {\n\t\tif (!this.coordinatorBridge) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[SectionEngineAdapter] resolveSectionController called without a coordinator.\",\n\t\t\t);\n\t\t}\n\t\treturn this.coordinatorBridge.resolveSectionController(args);\n\t}\n\n\t/**\n\t * Tear the adapter down. Safe to call more than once. Disposes the\n\t * coordinator bridge (which in turn disposes the section\n\t * controller for the current cohort), detaches the core\n\t * subscription, and clears subscribers.\n\t *\n\t * Does **not** dispose the framework-error bus — its lifetime is\n\t * owned by the toolkit CE / host.\n\t */\n\tasync dispose(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\t// Dispatch the FSM `dispose` input first so the disposed-stage\n\t\t// output flows through the bridges before we tear anything down.\n\t\tthis.core.dispatch({ kind: \"dispose\" });\n\t\tthis.unsubscribeCore();\n\t\tthis.subscriberFanout.dispose();\n\t\tif (this.coordinatorBridge) {\n\t\t\tawait this.coordinatorBridge.dispose();\n\t\t}\n\t}\n\n\tprivate routeOutputs(outputs: readonly SectionEngineOutput[]): void {\n\t\tfor (const output of outputs) {\n\t\t\tthis.routeOne(output);\n\t\t}\n\t\tthis.subscriberFanout.emit(outputs);\n\t}\n\n\tprivate routeOne(output: SectionEngineOutput): void {\n\t\tswitch (output.kind) {\n\t\t\tcase \"stage-change\":\n\t\t\tcase \"loading-complete\":\n\t\t\t\tthis.domEventBridge.dispatch(output);\n\t\t\t\tbreak;\n\t\t\tcase \"framework-error\":\n\t\t\t\tthis.domEventBridge.dispatch(output);\n\t\t\t\tthis.frameworkErrorBridge.dispatch(output);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = output;\n\t\t\t\tvoid exhaustive;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tthis.instrumentationBridge.dispatch(output);\n\t}\n}\n"]}
@@ -90,4 +90,3 @@ export interface CoordinatorBridgeHandle {
90
90
  dispose(): Promise<void>;
91
91
  }
92
92
  export declare function createCoordinatorBridge(options: CoordinatorBridgeOptions): CoordinatorBridgeHandle;
93
- //# sourceMappingURL=coordinator-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator-bridge.js","sourceRoot":"","sources":["../../../src/runtime/adapter/coordinator-bridge.ts"],"names":[],"m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ACL,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,YAAY,CAAC;QAC5B,YAAY,GAAG,IAAI,CAAC;QACpB,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC;gBACJ,MAAM,WAAW,CAAC,wBAAwB,CAAC;oBAC1C,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;iBACxC,CAAC,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CACX,wDAAwD,EACxD,KAAK,CACL,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"file":"coordinator-bridge.js","sourceRoot":"","sources":["../../../src/runtime/adapter/coordinator-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAyEH,MAAM,UAAU,uBAAuB,CACtC,OAAiC;IAEjC,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IAEnD,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,IAAI,YAAY,GAAqB,IAAI,CAAC;IAC1C,IAAI,qBAAqB,GAAwB,IAAI,CAAC;IACtD,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,MAAM,0BAA0B,GAAG,WAAW,CAAC,wBAAwB,CACtE,CAAC,KAAK,EAAE,EAAE;QACT,IAAI,CAAC;YACJ,iBAAiB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CACX,sDAAsD,EACtD,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC,CACD,CAAC;IAEF,SAAS,4BAA4B;QACpC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U,CAAC,SAAS,CAC3C,CAAC,MAA8B,EAAE,EAAE;gBAClC,IAAI,KAAK,KAAK,eAAe,IAAI,QAAQ;oBAAE,OAAO;gBAClD,IAAI,CAAC,oBAAoB,EAAE,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;YACtD,CAAC,CACD,CAAC;QACH,CAAC;QAED,iBAAiB,CAAC,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,UAAU,OAAO;QACrB,IAAI,QAAQ;YAAE,OAAO;QACrB,QAAQ,GAAG,IAAI,CAAC;QAChB,eAAe,IAAI,CAAC,CAAC;QACrB,4BAA4B,EAAE,CAAC;QAC/B,IAAI,CAAC;YACJ,0BAA0B,EAAE,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CACX,yDAAyD,EACzD,KAAK,CACL,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,YAAY,CAAC;QAC5B,YAAY,GAAG,IAAI,CAAC;QACpB,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC;gBACJ,MAAM,WAAW,CAAC,wBAAwB,CAAC;oBAC1C,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,SAAS;iBACxC,CAAC,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CACX,wDAAwD,EACxD,KAAK,CACL,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,EAAE,wBAAwB,EAAE,OAAO,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Coordinator bridge for the section runtime engine adapter (M7 —\n * Variant C, layered).\n *\n * Unlike the DOM / legacy / framework-error bridges (which translate\n * **outputs** into I/O), the coordinator bridge is an **input source**:\n * it listens to a `ToolkitCoordinator` and feeds the resulting events\n * into the core via the `dispatchCoreInput` callback supplied by the\n * adapter.\n *\n * Responsibilities:\n * 1. **Framework-error subscription.** When the coordinator reports\n * a framework error through its bus, dispatch a\n * `{ kind: \"framework-error\" }` core input. Listener isolation\n * matches `FrameworkErrorBus`: a throwing bridge handler is\n * caught and `console.warn`-logged so the original fan-out is\n * not interrupted.\n *\n * 2. **Section-controller resolution.** When the host calls\n * `resolveSectionController({ ... })`, the bridge invokes\n * `coordinator.getOrCreateSectionController({ ... })` and, on\n * successful resolution, dispatches\n * `{ kind: \"section-controller-resolved\" }` to the core. Init\n * tokens guard against late resolutions overwriting a more\n * recent cohort (mirrors `SectionRuntimeEngine.initialize`'s\n * `activeInitToken` pattern).\n *\n * 3. **Disposal.** On `dispose()`, the bridge unsubscribes from the\n * framework-error bus and (if the engine owns the section\n * controller for the cohort) calls\n * `coordinator.disposeSectionController({ ... })`. It does\n * **not** dispose the coordinator itself — the coordinator's\n * lifetime is owned by the toolkit CE / host, not by the engine.\n *\n * Disposal is idempotent: calling `dispose()` twice is a no-op.\n *\n * The bridge **must not** import `svelte`.\n */\n\nimport type {\n\tSectionControllerEvent,\n\tSectionControllerHandle,\n} from \"../../services/section-controller-types.js\";\nimport type { CohortKey } from \"../core/cohort.js\";\nimport type { SectionEngineInput } from \"../core/engine-input.js\";\n\n/**\n * Subset of the `ToolkitCoordinator` surface the bridge consumes. Kept\n * structural so tests can pass a fake without pulling the full\n * coordinator.\n */\nexport interface CoordinatorPort {\n\tsubscribeFrameworkErrors(\n\t\tlistener: (\n\t\t\tmodel: import(\"../../services/framework-error.js\").FrameworkErrorModel,\n\t\t) => void,\n\t): () => void;\n\n\tgetOrCreateSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t\tinput?: unknown;\n\t\tupdateExisting?: boolean;\n\t\tcreateDefaultController: () =>\n\t\t\t| SectionControllerHandle\n\t\t\t| Promise<SectionControllerHandle>;\n\t}): Promise<SectionControllerHandle>;\n\n\tdisposeSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t}): Promise<void>;\n}\n\nexport interface ResolveSectionControllerArgs {\n\tcohort: CohortKey;\n\tassessmentId: string;\n\tview: string;\n\tsection: unknown;\n\tcreateDefaultController: () =>\n\t\t| SectionControllerHandle\n\t\t| Promise<SectionControllerHandle>;\n\t/**\n\t * Optional callback invoked when the controller resolves and on\n\t * every controller `subscribe` event. The kernel uses this to keep\n\t * its composition snapshot in sync with the controller's view.\n\t *\n\t * The bridge is responsible for unsubscribing on dispose / cohort\n\t * change so a stale controller doesn't keep emitting after rollover.\n\t */\n\tonCompositionChanged?: (composition: unknown) => void;\n\t/**\n\t * Optional callback invoked once with the resolved controller handle\n\t * the moment it is available. Lets the host keep a reference for\n\t * direct method calls (e.g. `navigateToItem`, `applySession`)\n\t * without re-querying the coordinator.\n\t */\n\tonControllerResolved?: (controller: SectionControllerHandle) => void;\n}\n\nexport interface CoordinatorBridgeOptions {\n\tcoordinator: CoordinatorPort;\n\tdispatchCoreInput: (input: SectionEngineInput) => void;\n}\n\nexport interface CoordinatorBridgeHandle {\n\tresolveSectionController(args: ResolveSectionControllerArgs): Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nexport function createCoordinatorBridge(\n\toptions: CoordinatorBridgeOptions,\n): CoordinatorBridgeHandle {\n\tconst { coordinator, dispatchCoreInput } = options;\n\n\tlet activeInitToken = 0;\n\tlet activeCohort: CohortKey | null = null;\n\tlet unsubscribeController: (() => void) | null = null;\n\tlet disposed = false;\n\n\tconst unsubscribeFrameworkErrors = coordinator.subscribeFrameworkErrors(\n\t\t(model) => {\n\t\t\ttry {\n\t\t\t\tdispatchCoreInput({ kind: \"framework-error\", error: model });\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[CoordinatorBridge] framework-error dispatch failed:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\n\n\tfunction detachControllerSubscription(): void {\n\t\tif (!unsubscribeController) return;\n\t\ttry {\n\t\t\tunsubscribeController();\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"[CoordinatorBridge] controller unsubscribe failed:\", error);\n\t\t}\n\t\tunsubscribeController = null;\n\t}\n\n\tasync function resolveSectionController(\n\t\targs: ResolveSectionControllerArgs,\n\t): Promise<void> {\n\t\tif (disposed) return;\n\t\tactiveInitToken += 1;\n\t\tconst token = activeInitToken;\n\t\tactiveCohort = args.cohort;\n\n\t\tconst controller = await coordinator.getOrCreateSectionController({\n\t\t\tsectionId: args.cohort.sectionId,\n\t\t\tattemptId: args.cohort.attemptId || undefined,\n\t\t\tinput: {\n\t\t\t\tsection: args.section,\n\t\t\t\tsectionId: args.cohort.sectionId,\n\t\t\t\tassessmentId: args.assessmentId,\n\t\t\t\tview: args.view,\n\t\t\t},\n\t\t\tupdateExisting: true,\n\t\t\tcreateDefaultController: args.createDefaultController,\n\t\t});\n\n\t\t// Drop late resolutions — a cohort change or dispose may have\n\t\t// rolled the token forward while we awaited the coordinator.\n\t\tif (token !== activeInitToken || disposed) return;\n\n\t\tdetachControllerSubscription();\n\n\t\targs.onControllerResolved?.(controller);\n\n\t\tconst getCompositionModel = (\n\t\t\tcontroller as SectionControllerHandle & {\n\t\t\t\tgetCompositionModel?: () => unknown;\n\t\t\t}\n\t\t).getCompositionModel;\n\t\targs.onCompositionChanged?.(getCompositionModel?.());\n\n\t\tif (typeof controller.subscribe === \"function\") {\n\t\t\tunsubscribeController = controller.subscribe(\n\t\t\t\t(_event: SectionControllerEvent) => {\n\t\t\t\t\tif (token !== activeInitToken || disposed) return;\n\t\t\t\t\targs.onCompositionChanged?.(getCompositionModel?.());\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tdispatchCoreInput({ kind: \"section-controller-resolved\" });\n\t}\n\n\tasync function dispose(): Promise<void> {\n\t\tif (disposed) return;\n\t\tdisposed = true;\n\t\tactiveInitToken += 1;\n\t\tdetachControllerSubscription();\n\t\ttry {\n\t\t\tunsubscribeFrameworkErrors();\n\t\t} catch (error) {\n\t\t\tconsole.warn(\n\t\t\t\t\"[CoordinatorBridge] framework-error unsubscribe failed:\",\n\t\t\t\terror,\n\t\t\t);\n\t\t}\n\t\tconst cohort = activeCohort;\n\t\tactiveCohort = null;\n\t\tif (cohort) {\n\t\t\ttry {\n\t\t\t\tawait coordinator.disposeSectionController({\n\t\t\t\t\tsectionId: cohort.sectionId,\n\t\t\t\t\tattemptId: cohort.attemptId || undefined,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[CoordinatorBridge] section-controller dispose failed:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { resolveSectionController, dispose };\n}\n"]}
@@ -60,4 +60,3 @@ export interface DomEventBridgeHandle {
60
60
  setHost(host: EventTarget): void;
61
61
  }
62
62
  export declare function createDomEventBridge(options: DomEventBridgeOptions): DomEventBridgeHandle;
63
- //# sourceMappingURL=dom-event-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom-event-bridge.js","sourceRoot":"","sources":["../../../src/runtime/adapter/dom-event-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAoCH,MAAM,UAAU,oBAAoB,CACnC,OAA8B;IAE9B,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACxC,IAAI,IAAI,GAAgB,OAAO,CAAC,IAAI,CAAC;IACrC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAE5D,SAAS,mBAAmB,CAC3B,MAA8D;QAE9D,MAAM,MAAM,GAAsB;YACjC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS;YACT,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,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AE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * DOM event bridge for the section runtime engine adapter (M7 — Variant\n * C, layered).\n *\n * Translates canonical engine outputs (`stage-change`,\n * `loading-complete`, `framework-error`) into DOM `CustomEvent`\n * dispatches on the host element. Mirrors the kernel's existing\n * `dispatch(\"pie-stage-change\", …)` / `dispatch(\"pie-loading-complete\", …)`\n * / `dispatch(\"framework-error\", …)` emit chain bit-for-bit so the M6\n * canonical event surface stays stable while the kernel migrates onto\n * the engine in PR 5.\n *\n * **Detail-shape contract.** The engine core emits structurally minimal\n * outputs (`{ stage, status, cohort }`, `{ cohort, itemCount,\n * loadedCount }`). The bridge enriches them with `runtimeId`,\n * `sourceCe`, and `timestamp` so the dispatched DOM event detail\n * matches the legacy\n * `packages/players-shared/src/pie/stages.ts#StageChangeDetail` and\n * `LoadingCompleteDetail` shapes verbatim. `runtimeId` and `sourceCe`\n * are supplied at adapter construction time (one per engine instance);\n * `timestamp` is captured per-emit via the injected `now()` clock so\n * tests can pin a deterministic value.\n *\n * **Why not import the stage tracker.** The tracker's monotonic /\n * skipped-fill enforcement now lives in the engine core's transition\n * function. The bridge is purely an output-to-DOM translator — it does\n * not gate emissions, does not re-order, does not de-duplicate. That\n * keeps the responsibility clean and matches the \"outputs are already\n * ordered correctly by the core\" contract from\n * `engine-transition.ts`.\n *\n * The bridge **must not** import `svelte`; per the M7 layering\n * constraint the adapter is plain TS.\n */\n\nimport type {\n\tLoadingCompleteDetail,\n\tStageChangeDetail,\n} from \"@pie-players/pie-players-shared/pie\";\nimport type { SectionEngineOutput } from \"../core/engine-output.js\";\n\nexport interface DomEventBridgeOptions {\n\t/** Element on which to dispatch the DOM events. */\n\thost: EventTarget;\n\t/** Stable runtime id for this engine instance. */\n\truntimeId: string;\n\t/**\n\t * Tag name of the host CE without the `--version-<encoded>` suffix.\n\t * Each layout CE that mounts the kernel passes its own canonical tag\n\t * name; the toolkit CE passes its own.\n\t */\n\tsourceCe: string;\n\t/**\n\t * Clock injection for tests. Defaults to `() => new Date().toISOString()`.\n\t */\n\tnow?: () => string;\n}\n\nexport interface DomEventBridgeHandle {\n\t/** Translate a single engine output into a DOM dispatch. */\n\tdispatch(output: SectionEngineOutput): void;\n\t/**\n\t * Update the host element after construction (e.g. when the kernel\n\t * receives its host element via Svelte action / context). The\n\t * bridge keeps the latest host; future dispatches go to that host.\n\t */\n\tsetHost(host: EventTarget): void;\n}\n\nexport function createDomEventBridge(\n\toptions: DomEventBridgeOptions,\n): DomEventBridgeHandle {\n\tconst { runtimeId, sourceCe } = options;\n\tlet host: EventTarget = options.host;\n\tconst now = options.now ?? (() => new Date().toISOString());\n\n\tfunction dispatchStageChange(\n\t\toutput: Extract<SectionEngineOutput, { kind: \"stage-change\" }>,\n\t): void {\n\t\tconst detail: StageChangeDetail = {\n\t\t\tstage: output.stage,\n\t\t\tstatus: output.status,\n\t\t\truntimeId,\n\t\t\tsectionId: output.cohort?.sectionId,\n\t\t\tattemptId: output.cohort?.attemptId ? output.cohort.attemptId : undefined,\n\t\t\ttimestamp: now(),\n\t\t\tsourceCe,\n\t\t};\n\t\thost.dispatchEvent(\n\t\t\tnew CustomEvent<StageChangeDetail>(\"pie-stage-change\", { detail }),\n\t\t);\n\t}\n\n\tfunction dispatchLoadingComplete(\n\t\toutput: Extract<SectionEngineOutput, { kind: \"loading-complete\" }>,\n\t): void {\n\t\tconst detail: LoadingCompleteDetail = {\n\t\t\truntimeId,\n\t\t\tsectionId: output.cohort.sectionId,\n\t\t\tattemptId: output.cohort.attemptId ? output.cohort.attemptId : undefined,\n\t\t\titemCount: output.itemCount,\n\t\t\tloadedCount: output.loadedCount,\n\t\t\ttimestamp: now(),\n\t\t\tsourceCe,\n\t\t};\n\t\thost.dispatchEvent(\n\t\t\tnew CustomEvent<LoadingCompleteDetail>(\"pie-loading-complete\", {\n\t\t\t\tdetail,\n\t\t\t}),\n\t\t);\n\t}\n\n\tfunction dispatchFrameworkError(\n\t\toutput: Extract<SectionEngineOutput, { kind: \"framework-error\" }>,\n\t): void {\n\t\t// Mirror the kernel's existing surface — the `framework-error`\n\t\t// DOM event detail is the framework-error model. The\n\t\t// `framework-error-bridge` separately reports the same model\n\t\t// into the bus so subscribers see one fan-out per error.\n\t\thost.dispatchEvent(\n\t\t\tnew CustomEvent(\"framework-error\", { detail: output.error }),\n\t\t);\n\t}\n\n\tfunction dispatch(output: SectionEngineOutput): void {\n\t\tswitch (output.kind) {\n\t\t\tcase \"stage-change\":\n\t\t\t\tdispatchStageChange(output);\n\t\t\t\treturn;\n\t\t\tcase \"loading-complete\":\n\t\t\t\tdispatchLoadingComplete(output);\n\t\t\t\treturn;\n\t\t\tcase \"framework-error\":\n\t\t\t\tdispatchFrameworkError(output);\n\t\t\t\treturn;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = output;\n\t\t\t\tvoid exhaustive;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction setHost(next: EventTarget): void {\n\t\thost = next;\n\t}\n\n\treturn { dispatch, setHost };\n}\n"]}
@@ -34,4 +34,3 @@ export interface FrameworkErrorBridgeHandle {
34
34
  dispatch(output: SectionEngineOutput): void;
35
35
  }
36
36
  export declare function createFrameworkErrorBridge(options: FrameworkErrorBridgeOptions): FrameworkErrorBridgeHandle;
37
- //# sourceMappingURL=framework-error-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"framework-error-bridge.js","sourceRoot":"","sources":["../../../src/runtime/adapter/framework-error-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAaH,MAAM,UAAU,0BAA0B,CACzC,OAAoC;IAEpC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAExB,SAAS,QAAQ,CAAC,MAA2B;QAC5C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,iBAAiB;gBACrB,GAAG,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvC,OAAO;YACR,KAAK,cAAc,CAAC;YACpB,KAAK,kBAAkB;gBACtB,OAAO;YACR,OAAO,CAAC,CAAC,CAAC;gBACT,MAAM,UAAU,GAAU,MAAM,CAAC;gBACjC,KAAK,UAAU,CAAC;gBAChB,OAAO;YACR,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"framework-error-bridge.js","sourceRoot":"","sources":["../../../src/runtime/adapter/framework-error-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAaH,MAAM,UAAU,0BAA0B,CACzC,OAAoC;IAEpC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAExB,SAAS,QAAQ,CAAC,MAA2B;QAC5C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,iBAAiB;gBACrB,GAAG,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvC,OAAO;YACR,KAAK,cAAc,CAAC;YACpB,KAAK,kBAAkB;gBACtB,OAAO;YACR,OAAO,CAAC,CAAC,CAAC;gBACT,MAAM,UAAU,GAAU,MAAM,CAAC;gBACjC,KAAK,UAAU,CAAC;gBAChB,OAAO;YACR,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Framework-error bridge for the section runtime engine adapter (M7 —\n * Variant C, layered).\n *\n * Routes `framework-error` engine outputs into a `FrameworkErrorBus`\n * (write side: `FrameworkErrorReporter`). The bus is the single\n * fan-out point shared with the toolkit CE's banner, the coordinator's\n * canonical `onFrameworkError` lifecycle hook, and any direct host\n * subscribers via `subscribeFrameworkErrors`. See\n * `packages/assessment-toolkit/src/services/framework-error-bus.ts`\n * for the full bus contract.\n *\n * **Why a separate bridge.** The dom-event-bridge dispatches the\n * `framework-error` DOM event on the host. The framework-error-bridge\n * routes the same model into the in-process bus so listeners that\n * subscribe via `coordinator.subscribeFrameworkErrors(...)` see the\n * same fan-out with byte-identical payloads. Splitting the\n * responsibilities lets a host opt out of either side (DOM-only or\n * bus-only) without re-implementing the other.\n *\n * **Bus ownership.** The bridge does not construct the bus; the\n * adapter receives one externally so the toolkit CE can keep sharing\n * its bus with the coordinator (matching today's\n * `PieAssessmentToolkit.svelte` lifetime model). This avoids the\n * \"second bus\" pitfall — a dual-bus topology would silently fragment\n * fan-out.\n */\n\nimport type { FrameworkErrorReporter } from \"../../services/framework-error-bus.js\";\nimport type { SectionEngineOutput } from \"../core/engine-output.js\";\n\nexport interface FrameworkErrorBridgeOptions {\n\tbus: FrameworkErrorReporter;\n}\n\nexport interface FrameworkErrorBridgeHandle {\n\tdispatch(output: SectionEngineOutput): void;\n}\n\nexport function createFrameworkErrorBridge(\n\toptions: FrameworkErrorBridgeOptions,\n): FrameworkErrorBridgeHandle {\n\tconst { bus } = options;\n\n\tfunction dispatch(output: SectionEngineOutput): void {\n\t\tswitch (output.kind) {\n\t\t\tcase \"framework-error\":\n\t\t\t\tbus.reportFrameworkError(output.error);\n\t\t\t\treturn;\n\t\t\tcase \"stage-change\":\n\t\t\tcase \"loading-complete\":\n\t\t\t\treturn;\n\t\t\tdefault: {\n\t\t\t\tconst exhaustive: never = output;\n\t\t\t\tvoid exhaustive;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { dispatch };\n}\n"]}
@@ -29,4 +29,3 @@ export interface InstrumentationBridgeHandle {
29
29
  setHook(hook: InstrumentationHook | undefined): void;
30
30
  }
31
31
  export declare function createInstrumentationBridge(options?: InstrumentationBridgeOptions): InstrumentationBridgeHandle;
32
- //# sourceMappingURL=instrumentation-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation-bridge.js","sourceRoot":"","sources":["../../../src/runtime/adapter/instrumentation-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAeH,MAAM,UAAU,2BAA2B,CAC1C,UAAwC,EAAE;IAE1C,IAAI,IAAI,GAAoC,OAAO,CAAC,IAAI,CAAC;IAEzD,SAAS,QAAQ,CAAC,MAA2B;QAC5C,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,CAAC;YACJ,IAAI,CAAC,MAAM,CAAC,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;IACF,CAAC;IAED,SAAS,OAAO,CAAC,IAAqC;QACrD,IAAI,GAAG,IAAI,CAAC;IACb,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
1
+ {"version":3,"file":"instrumentation-bridge.js","sourceRoot":"","sources":["../../../src/runtime/adapter/instrumentation-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAeH,MAAM,UAAU,2BAA2B,CAC1C,UAAwC,EAAE;IAE1C,IAAI,IAAI,GAAoC,OAAO,CAAC,IAAI,CAAC;IAEzD,SAAS,QAAQ,CAAC,MAA2B;QAC5C,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,IAAI,CAAC;YACJ,IAAI,CAAC,MAAM,CAAC,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;IACF,CAAC;IAED,SAAS,OAAO,CAAC,IAAqC;QACrD,IAAI,GAAG,IAAI,CAAC;IACb,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Instrumentation bridge for the section runtime engine adapter (M7 —\n * Variant C, layered).\n *\n * Forwards every `SectionEngineOutput` to an optional observability\n * hook the host injects (telemetry, debug logger, e2e probe). The\n * bridge is intentionally thin: it does not buffer, transform, or\n * filter. Hosts that need a different shape can run their own subscriber\n * via the adapter's public `subscribe(...)` channel.\n *\n * **Why a dedicated bridge instead of a generic subscriber.** The\n * subscriber-fanout channel is host-shaped — listeners receive batched\n * arrays of outputs per `core.dispatch` call so they can reason about\n * \"what happened in this transition.\" The instrumentation hook is\n * per-output: telemetry pipelines want one record per stage change,\n * one record per readiness flip, etc. Splitting the channels keeps\n * both shapes ergonomic.\n *\n * The bridge **must not** import `svelte` per the M7 layering\n * constraint.\n */\n\nimport type { SectionEngineOutput } from \"../core/engine-output.js\";\n\nexport type InstrumentationHook = (output: SectionEngineOutput) => void;\n\nexport interface InstrumentationBridgeOptions {\n\thook?: InstrumentationHook;\n}\n\nexport interface InstrumentationBridgeHandle {\n\tdispatch(output: SectionEngineOutput): void;\n\tsetHook(hook: InstrumentationHook | undefined): void;\n}\n\nexport function createInstrumentationBridge(\n\toptions: InstrumentationBridgeOptions = {},\n): InstrumentationBridgeHandle {\n\tlet hook: InstrumentationHook | undefined = options.hook;\n\n\tfunction dispatch(output: SectionEngineOutput): void {\n\t\tif (!hook) return;\n\t\ttry {\n\t\t\thook(output);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"[InstrumentationBridge] hook failed:\", error);\n\t\t}\n\t}\n\n\tfunction setHook(next: InstrumentationHook | undefined): void {\n\t\thook = next;\n\t}\n\n\treturn { dispatch, setHook };\n}\n"]}
@@ -32,4 +32,3 @@ export interface SubscriberFanoutHandle {
32
32
  getListenerCount(): number;
33
33
  }
34
34
  export declare function createSubscriberFanout(): SubscriberFanoutHandle;
35
- //# sourceMappingURL=subscriber-fanout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscriber-fanout.js","sourceRoot":"","sources":["../../../src/runtime/adapter/subscriber-fanout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAeH,MAAM,UAAU,sBAAsB;IACrC,MAAM,SAAS,GAAG,IAA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S,IAAI,CAAC,OAAuC;QACpD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACjC,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9C,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC;gBACJ,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;IACF,CAAC;IAED,SAAS,SAAS,CAAC,QAA8B;QAChD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACxB,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,QAAQ;gBAAE,OAAO;YACtB,QAAQ,GAAG,KAAK,CAAC;YACjB,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC,CAAC;IACH,CAAC;IAED,SAAS,OAAO;QACf,SAAS,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;IAED,SAAS,gBAAgB;QACxB,OAAO,SAAS,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AACvD,CAAC","sourcesContent":["/**\n * Subscriber fan-out for the section runtime engine adapter (M7 — Variant\n * C, layered).\n *\n * The adapter exposes a single `subscribe(listener)` channel for hosts\n * that want a synchronous stream of `SectionEngineOutput[]` batches —\n * one batch per `core.dispatch(input)` call.\n *\n * **Why not reuse `SectionEngineCore.subscribe` directly.** The core\n * channel is the engine's internal contract. The fan-out is the\n * adapter's public channel: it is the single seam every facade method\n * goes through, and the only seam that ever sees host-side errors. The\n * separation lets us swap the core implementation (or skip it for\n * tests) without changing the public subscriber shape.\n *\n * **Subscriber contract.** Mirrors `SectionEngineCore.subscribe`:\n * - Listeners are invoked synchronously, in registration order.\n * - A listener that throws is caught and `console.warn`-logged. Fan-out\n * is not interrupted — same isolation guarantee as\n * `FrameworkErrorBus`.\n * - The disposer returned from `subscribe` is idempotent.\n * - Listeners receive a frozen, defensively-copied output array.\n * - There is no replay; subscribe at adapter construction time if you\n * need every output from `idle` onward.\n */\n\nimport type { SectionEngineOutput } from \"../core/engine-output.js\";\n\nexport type EngineOutputListener = (\n\toutputs: readonly SectionEngineOutput[],\n) => void;\n\nexport interface SubscriberFanoutHandle {\n\temit(outputs: readonly SectionEngineOutput[]): void;\n\tsubscribe(listener: EngineOutputListener): () => void;\n\tdispose(): void;\n\tgetListenerCount(): number;\n}\n\nexport function createSubscriberFanout(): SubscriberFanoutHandle {\n\tconst listeners = new Set<EngineOutputListener>();\n\n\tfunction emit(outputs: readonly SectionEngineOutput[]): void {\n\t\tif (outputs.length === 0) return;\n\t\tconst snapshot = Array.from(listeners);\n\t\tconst frozen = Object.freeze(outputs.slice());\n\t\tfor (const listener of snapshot) {\n\t\t\ttry {\n\t\t\t\tlistener(frozen);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\"[SubscriberFanout] listener failed:\", error);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction subscribe(listener: EngineOutputListener): () => void {\n\t\tlisteners.add(listener);\n\t\tlet attached = true;\n\t\treturn () => {\n\t\t\tif (!attached) return;\n\t\t\tattached = false;\n\t\t\tlisteners.delete(listener);\n\t\t};\n\t}\n\n\tfunction dispose(): void {\n\t\tlisteners.clear();\n\t}\n\n\tfunction getListenerCount(): number {\n\t\treturn listeners.size;\n\t}\n\n\treturn { emit, subscribe, dispose, getListenerCount };\n}\n"]}
@@ -49,4 +49,3 @@ export declare class SectionEngineCore {
49
49
  disposeListeners(): void;
50
50
  private fanOut;
51
51
  }
52
- //# sourceMappingURL=SectionEngineCore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SectionEngineCore.js","sourceRoot":"","sources":["../../../src/runtime/core/SectionEngineCore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EACN,wBAAwB,GAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMpD,MAAM,OAAO,iBAAiB;IACrB,KAAK,GAAuB,wBAAwB,EAAE,CAAC;IAC9C,SAAS,GAAG,IAAI,GAAG,EAA6B,CAAC;IAElE,6EAA6E;IAC7E,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAyB;QACjC,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,QAAmC;QAC5C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,QAAQ;gBAAE,OAAO;YACtB,QAAQ,GAAG,KAAK,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,gBAAgB;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,EAA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,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,QAAmC;QAC5C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,QAAQ;gBAAE,OAAO;YACtB,QAAQ,GAAG,KAAK,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,gBAAgB;QACf,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEO,MAAM,CAAC,OAA8B;QAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9C,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC;gBACJ,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Section runtime engine — pure core (M7 — Variant C, layered).\n *\n * `SectionEngineCore` is a thin object oriented wrapper over the pure\n * `transition()` function. It owns the current `SectionEngineState`,\n * applies inputs serially, and fans out the resulting\n * `SectionEngineOutput[]` to subscribers. There is no DOM, Svelte,\n * coordinator, or timing dependency in this module — all I/O lives in\n * the adapter layer (PR 2).\n *\n * Lifetime model:\n * - One instance per cohort logical lifetime. Cohort changes happen\n * through `dispatch({ kind: \"cohort-change\" })`, not through\n * re-construction.\n * - After a `dispose` input, additional inputs are no-ops (the\n * transition handles this), but subscribers stay attached so the\n * adapter can still deliver final cleanup outputs.\n *\n * Subscriber contract:\n * - Listeners are invoked synchronously, in registration order.\n * - A throwing listener is caught and `console.warn`-logged. Fan-out\n * is not interrupted — same isolation guarantee as\n * `FrameworkErrorBus`.\n * - The disposer returned from `subscribe` is idempotent.\n * - Listeners receive only the output array. State snapshots are\n * read via `getState()` for callers that need them.\n */\n\nimport type { SectionEngineInput } from \"./engine-input.js\";\nimport type { SectionEngineOutput } from \"./engine-output.js\";\nimport {\n\tcreateInitialEngineState,\n\ttype SectionEngineState,\n} from \"./engine-state.js\";\nimport { transition } from \"./engine-transition.js\";\n\nexport type SectionEngineCoreListener = (\n\toutputs: readonly SectionEngineOutput[],\n) => void;\n\nexport class SectionEngineCore {\n\tprivate state: SectionEngineState = createInitialEngineState();\n\tprivate readonly listeners = new Set<SectionEngineCoreListener>();\n\n\t/** Read-only state snapshot. Callers must not mutate the returned object. */\n\tgetState(): Readonly<SectionEngineState> {\n\t\treturn this.state;\n\t}\n\n\t/**\n\t * Apply one input. Returns the outputs that resulted from the\n\t * transition; subscribers also receive them.\n\t */\n\tdispatch(input: SectionEngineInput): readonly SectionEngineOutput[] {\n\t\tconst result = transition(this.state, input);\n\t\tthis.state = result.state;\n\t\tif (result.outputs.length > 0) {\n\t\t\tthis.fanOut(result.outputs);\n\t\t}\n\t\treturn result.outputs;\n\t}\n\n\t/**\n\t * Subscribe to engine outputs. Returns an idempotent disposer.\n\t * Listeners do not receive a replay of past outputs; subscribe at\n\t * construction time if you need every output from `idle` onward.\n\t */\n\tsubscribe(listener: SectionEngineCoreListener): () => void {\n\t\tthis.listeners.add(listener);\n\t\tlet attached = true;\n\t\treturn () => {\n\t\t\tif (!attached) return;\n\t\t\tattached = false;\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/** Test-only: detach every listener. */\n\tdisposeListeners(): void {\n\t\tthis.listeners.clear();\n\t}\n\n\tprivate fanOut(outputs: SectionEngineOutput[]): void {\n\t\tconst snapshot = Array.from(this.listeners);\n\t\tconst frozen = Object.freeze(outputs.slice());\n\t\tfor (const listener of snapshot) {\n\t\t\ttry {\n\t\t\t\tlistener(frozen);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\"[SectionEngineCore] listener failed:\", error);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -37,4 +37,3 @@ export declare function makeCohort(args: {
37
37
  sectionId: string | null | undefined;
38
38
  attemptId: string | null | undefined;
39
39
  }): CohortKey | null;
40
- //# sourceMappingURL=cohort.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cohort.js","sourceRoot":"","sources":["../../../src/runtime/core/cohort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAwB;IACjD,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAmB,EAAE,CAAmB;IACpE,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAG1B;IACA,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO;QACN,SAAS;QACT,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;KAC/B,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"cohort.js","sourceRoot":"","sources":["../../../src/runtime/core/cohort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AASH;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAwB;IACjD,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAmB,EAAE,CAAmB;IACpE,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAG1B;IACA,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO;QACN,SAAS;QACT,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;KAC/B,CAAC;AACH,CAAC","sourcesContent":["/**\n * Cohort identity for the section runtime engine (M7).\n *\n * One cohort is the tuple `(sectionId, attemptId)` for the section the\n * host is currently rendering. Stage progression, readiness latches, and\n * `pie-loading-complete` emission are all gated on this tuple — when it\n * changes, the engine emits `disposed` for the outgoing cohort and\n * resets to `composed` for the new one.\n *\n * `attemptId` is optional in the public surface (per the toolkit /\n * layout-CE prop shape) but the engine carries it as the empty string\n * when absent so the cohort key is total.\n */\n\nexport interface CohortKey {\n\t/** Section identifier; required for any non-idle cohort. */\n\tsectionId: string;\n\t/** Attempt identifier; empty string if the host did not provide one. */\n\tattemptId: string;\n}\n\n/**\n * Stable string form of the cohort tuple used as a key for the\n * `loadingCompleteEmittedForCohort` latch and equality checks.\n */\nexport function cohortKey(cohort: CohortKey | null): string {\n\tif (!cohort) return \"\";\n\treturn `${cohort.sectionId}|${cohort.attemptId}`;\n}\n\n/**\n * `true` iff the two cohorts have the same `(sectionId, attemptId)` pair.\n * Treats both inputs as identifying the cohort by value, never by\n * reference.\n */\nexport function cohortsEqual(a: CohortKey | null, b: CohortKey | null): boolean {\n\tif (a === b) return true;\n\tif (!a || !b) return false;\n\treturn a.sectionId === b.sectionId && a.attemptId === b.attemptId;\n}\n\n/**\n * Normalize host-provided `(sectionId, attemptId)` into a cohort. Returns\n * `null` when the section identifier is empty — that is the engine's\n * idle state (no cohort).\n */\nexport function makeCohort(args: {\n\tsectionId: string | null | undefined;\n\tattemptId: string | null | undefined;\n}): CohortKey | null {\n\tconst sectionId = args.sectionId ?? \"\";\n\tif (!sectionId) return null;\n\treturn {\n\t\tsectionId,\n\t\tattemptId: args.attemptId ?? \"\",\n\t};\n}\n"]}
@@ -111,4 +111,3 @@ export type SectionEngineInput = EngineInputInitialize | EngineInputUpdateRuntim
111
111
  * from a single place when it constructs `initialize` inputs.
112
112
  */
113
113
  export type { RuntimeInputs };
114
- //# sourceMappingURL=engine-input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-input.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
1
+ {"version":3,"file":"engine-input.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG","sourcesContent":["/**\n * Section runtime engine inputs (M7 — Variant C, layered core).\n *\n * Inputs are the discriminated union of events the adapter (PR 2) feeds\n * into the pure transition function (`engine-transition.ts`). The shape\n * is closed: every field is plain data so the transition can be tested\n * without any DOM, Svelte, or coordinator wiring.\n *\n * Adapter→core boundary contract:\n * - The adapter never mutates engine state directly. It always\n * constructs an input and calls `core.dispatch(input)`.\n * - Inputs are total: an unhandled `kind` is a programming error\n * (the transition uses `assertNever` exhaustiveness).\n * - Inputs carry only data, never live host references that would\n * pin lifetime. Coordinator and controller handles live in the\n * adapter; the core only sees readiness signals derived from them.\n */\n\nimport type { CohortKey } from \"./cohort.js\";\nimport type {\n\tEffectiveRuntime,\n\tRuntimeInputs,\n} from \"./engine-resolver.js\";\nimport type { EngineReadinessSignals } from \"./engine-readiness.js\";\nimport type { FrameworkErrorModel } from \"../../services/framework-error.js\";\n\n/**\n * `initialize` is the first transition out of `idle`. It carries the\n * cohort key and the resolved runtime/tools snapshot for the cohort.\n * The adapter constructs this input after running the resolver against\n * the host's two-tier inputs.\n */\nexport type EngineInputInitialize = {\n\tkind: \"initialize\";\n\tcohort: CohortKey;\n\teffectiveRuntime: EffectiveRuntime;\n\teffectiveToolsConfig: unknown;\n\titemCount: number;\n};\n\n/**\n * `update-runtime` is sent when the host two-tier inputs change but\n * the cohort does not. The transition stores the latest resolver\n * output without changing phase; readiness gates and stage progression\n * stay where they are.\n */\nexport type EngineInputUpdateRuntime = {\n\tkind: \"update-runtime\";\n\teffectiveRuntime: EffectiveRuntime;\n\teffectiveToolsConfig: unknown;\n};\n\n/**\n * `cohort-change` is sent when `(sectionId, attemptId)` changes. The\n * transition emits `disposed` for the outgoing cohort, resets state\n * to `booting-section` for the new one, and re-arms latches.\n */\nexport type EngineInputCohortChange = {\n\tkind: \"cohort-change\";\n\tcohort: CohortKey;\n\teffectiveRuntime: EffectiveRuntime;\n\teffectiveToolsConfig: unknown;\n\titemCount: number;\n};\n\n/**\n * `section-controller-resolved` is sent when the coordinator returns\n * the controller for the current cohort. Advances the phase from\n * `booting-section` → `engine-ready` (assuming `composed` is already\n * implied by `phase >= booting-section`, which the FSM treats as\n * monotonic).\n */\nexport type EngineInputSectionControllerResolved = {\n\tkind: \"section-controller-resolved\";\n};\n\n/**\n * `update-readiness-signals` carries the latest readiness snapshot\n * from the host. The transition uses it to gate the move into\n * `interactive` and to decide whether to emit `loading-complete`.\n *\n * The full signal set is sent every time so the transition does not\n * have to reason about partial overlays.\n */\nexport type EngineInputUpdateReadinessSignals = {\n\tkind: \"update-readiness-signals\";\n\tsignals: EngineReadinessSignals;\n\tloadedCount: number;\n\titemCount: number;\n\t/**\n\t * Strict-mode gate. When `\"strict\"`, `interactive` only fires\n\t * after `allLoadingComplete`; in `\"progressive\"`, `interactionReady`\n\t * is sufficient. Carried per-input so the host can reconfigure\n\t * mode mid-cohort without re-initializing.\n\t */\n\tmode: \"progressive\" | \"strict\";\n};\n\n/**\n * `framework-error` is sent for every framework-error report (M3\n * canonical channel). The transition records the latest error in\n * state and emits a `framework-error` output so the adapter can fan\n * out to subscribers and the DOM event.\n */\nexport type EngineInputFrameworkError = {\n\tkind: \"framework-error\";\n\terror: FrameworkErrorModel;\n};\n\n/**\n * `dispose` tears the engine down. Emits `disposed` for the current\n * cohort (if any) and moves to the terminal `disposed` phase. After\n * dispose the engine accepts no further inputs (the transition logs\n * a warning and is a no-op).\n */\nexport type EngineInputDispose = {\n\tkind: \"dispose\";\n};\n\nexport type SectionEngineInput =\n\t| EngineInputInitialize\n\t| EngineInputUpdateRuntime\n\t| EngineInputCohortChange\n\t| EngineInputSectionControllerResolved\n\t| EngineInputUpdateReadinessSignals\n\t| EngineInputFrameworkError\n\t| EngineInputDispose;\n\n/**\n * Convenience re-export so the adapter can import `RuntimeInputs`\n * from a single place when it constructs `initialize` inputs.\n */\nexport type { RuntimeInputs };\n"]}
@@ -59,4 +59,3 @@ export type EngineOutputFrameworkError = {
59
59
  error: FrameworkErrorModel;
60
60
  };
61
61
  export type SectionEngineOutput = EngineOutputStageChange | EngineOutputLoadingComplete | EngineOutputFrameworkError;
62
- //# sourceMappingURL=engine-output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-output.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
1
+ {"version":3,"file":"engine-output.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG","sourcesContent":["/**\n * Section runtime engine outputs (M7 — Variant C, layered core).\n *\n * Outputs are the closed discriminated union of effects the transition\n * function returns. The adapter (PR 2) takes the output array, walks\n * it in order, and dispatches each one to the right bridge (DOM\n * events, framework-error bus, subscriber fan-out).\n *\n * Outputs carry only plain data so the transition table can be tested\n * exhaustively without any DOM or coordinator wiring.\n *\n * Adjustment A2 from the M7 implementation plan: `loading-complete`\n * is an output, **not** an FSM phase. The transition emits it from\n * the `interactive` phase when the readiness signals indicate every\n * item has finished loading. This mirrors today's\n * `pie-loading-complete` DOM event semantics.\n *\n * The deprecated readiness output kinds (`readiness-change`,\n * `interaction-ready`, `ready`) were removed in the broad\n * architecture review compat sweep along with their DOM-event bridge\n * (`legacy-event-bridge.ts`). Stage and readiness changes now flow\n * through `stage-change` (with `EngineReadinessDetail` available via\n * `SectionEngineCore.getState()` / kernel `selectReadiness()`); the\n * \"all items loaded\" signal flows through `loading-complete` only.\n */\n\nimport type { Stage, StageStatus } from \"@pie-players/pie-players-shared/pie\";\nimport type { CohortKey } from \"./cohort.js\";\nimport type { FrameworkErrorModel } from \"../../services/framework-error.js\";\n\n/**\n * Stage transition. The adapter dispatches a `pie-stage-change` DOM\n * event with the canonical detail and forwards to subscribers /\n * coordinator. The status indicates whether the stage was entered,\n * skipped, or recorded as failed.\n */\nexport type EngineOutputStageChange = {\n\tkind: \"stage-change\";\n\tstage: Stage;\n\tstatus: StageStatus;\n\tcohort: CohortKey | null;\n};\n\n/**\n * Canonical `pie-loading-complete` emit (M6 D1). One-shot per cohort.\n * Fires from the `interactive` phase when loaded == items count and\n * the readiness signals satisfy `allLoadingComplete`.\n */\nexport type EngineOutputLoadingComplete = {\n\tkind: \"loading-complete\";\n\tcohort: CohortKey;\n\titemCount: number;\n\tloadedCount: number;\n};\n\n/**\n * Framework error fan-out. Mirrors the M3 `framework-error` DOM event\n * and the `subscribeFrameworkErrors` listener channel. Emitted on\n * every `framework-error` input.\n */\nexport type EngineOutputFrameworkError = {\n\tkind: \"framework-error\";\n\terror: FrameworkErrorModel;\n};\n\nexport type SectionEngineOutput =\n\t| EngineOutputStageChange\n\t| EngineOutputLoadingComplete\n\t| EngineOutputFrameworkError;\n"]}
@@ -46,4 +46,3 @@ export declare function createReadinessDetail(args: {
46
46
  signals: EngineReadinessSignals;
47
47
  reason?: string;
48
48
  }): EngineReadinessDetail;
49
- //# sourceMappingURL=engine-readiness.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-readiness.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-readiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAiCH,MAAM,UAAU,qBAAqB,CACpC,OAA+B;IAE/B,IAAI,OAAO,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC;IACzC,IAAI,OAAO,CAAC,kBAAkB;QAAE,OAAO,OAAO,CAAC;IAC/C,IAAI,OAAO,CAAC,gBAAgB;QAAE,OAAO,mBAAmB,CAAC;IACzD,IAAI,OAAO,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAIrC;IACA,8EAA8E;IAC9E,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;IAChF,MAAM,gBAAgB,GACrB,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACrE,MAAM,KAAK,GAAG,qBAAqB,CAAC;QACnC,GAAG,IAAI,CAAC,OAAO;QACf,kBAAkB,EAAE,UAAU;QAC9B,gBAAgB;KAChB,CAAC,CAAC;IAEH,OAAO;QACN,KAAK;QACL,gBAAgB;QAChB,kBAAkB,EAAE,UAAU;QAC9B,MAAM,EAAE,IAAI,CAAC,MAAM;KACnB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"engine-readiness.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-readiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAiCH,MAAM,UAAU,qBAAqB,CACpC,OAA+B;IAE/B,IAAI,OAAO,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC;IACzC,IAAI,OAAO,CAAC,kBAAkB;QAAE,OAAO,OAAO,CAAC;IAC/C,IAAI,OAAO,CAAC,gBAAgB;QAAE,OAAO,mBAAmB,CAAC;IACzD,IAAI,OAAO,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAIrC;IACA,8EAA8E;IAC9E,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;IAChF,MAAM,gBAAgB,GACrB,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACrE,MAAM,KAAK,GAAG,qBAAqB,CAAC;QACnC,GAAG,IAAI,CAAC,OAAO;QACf,kBAAkB,EAAE,UAAU;QAC9B,gBAAgB;KAChB,CAAC,CAAC;IAEH,OAAO;QACN,KAAK;QACL,gBAAgB;QAChB,kBAAkB,EAAE,UAAU;QAC9B,MAAM,EAAE,IAAI,CAAC,MAAM;KACnB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Readiness derivation for the section runtime engine (M7).\n *\n * Canonical home of `createReadinessDetail` and `resolveReadinessPhase`.\n * As of M7 PR 7 the previous duplicates in\n * `packages/section-player/src/components/shared/section-player-readiness.ts`\n * have been deleted; section-player now consumes these helpers via\n * `@pie-players/pie-assessment-toolkit/runtime/internal`.\n *\n * Type duplication note: the public DOM-event detail aliases\n * (`SectionPlayerReadinessChangeDetail` /\n * `SectionPlayerReadinessPhase`) still live in section-player's\n * `contracts/public-events.ts` because that file is part of section-\n * player's published custom-element contract. The toolkit core defines\n * `EngineReadinessPhase` independently so it has zero section-player\n * imports. The two definitions must stay structurally identical;\n * that invariant is covered by the readiness assertions in this\n * package's tests, which mirror the section-player suite.\n */\n\n/**\n * Coarse readiness phase label, derived from the four readiness\n * signals. Surfaced via the kernel's `selectReadiness()` /\n * `getSnapshot().readiness` selectors; M6 stages own the stage-level\n * transitions on `pie-stage-change` and use this phase as a\n * convenience label only. The deprecated `readiness-change` DOM\n * event that used to surface this directly was removed in the broad\n * architecture review compat sweep alongside its\n * `legacy-event-bridge`.\n */\nexport type EngineReadinessPhase =\n\t| \"bootstrapping\"\n\t| \"interaction-ready\"\n\t| \"loading\"\n\t| \"ready\"\n\t| \"error\";\n\nexport type EngineReadinessSignals = {\n\tsectionReady: boolean;\n\tinteractionReady: boolean;\n\tallLoadingComplete: boolean;\n\truntimeError: boolean;\n};\n\nexport type EngineReadinessDetail = {\n\tphase: EngineReadinessPhase;\n\tinteractionReady: boolean;\n\tallLoadingComplete: boolean;\n\treason?: string;\n};\n\nexport function resolveReadinessPhase(\n\tsignals: EngineReadinessSignals,\n): EngineReadinessPhase {\n\tif (signals.runtimeError) return \"error\";\n\tif (signals.allLoadingComplete) return \"ready\";\n\tif (signals.interactionReady) return \"interaction-ready\";\n\tif (signals.sectionReady) return \"loading\";\n\treturn \"bootstrapping\";\n}\n\nexport function createReadinessDetail(args: {\n\tmode: \"progressive\" | \"strict\";\n\tsignals: EngineReadinessSignals;\n\treason?: string;\n}): EngineReadinessDetail {\n\t// Final ready must always be gated by section lifecycle and complete loading.\n\tconst finalReady = args.signals.sectionReady && args.signals.allLoadingComplete;\n\tconst interactionReady =\n\t\targs.mode === \"strict\" ? finalReady : args.signals.interactionReady;\n\tconst phase = resolveReadinessPhase({\n\t\t...args.signals,\n\t\tallLoadingComplete: finalReady,\n\t\tinteractionReady,\n\t});\n\n\treturn {\n\t\tphase,\n\t\tinteractionReady,\n\t\tallLoadingComplete: finalReady,\n\t\treason: args.reason,\n\t};\n}\n"]}
@@ -171,4 +171,3 @@ export declare function resolveSectionEngineRuntimeState<P>(args: RuntimeInputs,
171
171
  effectiveRuntime: EffectiveRuntime;
172
172
  playerRuntime: P;
173
173
  };
174
- //# sourceMappingURL=engine-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-resolver.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAG3D,CAAC;AA2EF;;;;GAIG;AACH,SAAS,IAAI,CACZ,UAAyB,EACzB,OAAsB;IAEtB,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAGvC;IACA,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,CAAC,gBAAgB,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,gBAAgB,CAAC;IAChE,OAAO,IAAI,CAAC,gBAAgB,CAAC;AAC9B,CAAC;AAED,MA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KACzC,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,CAAC;QAC/C,gBAAgB,EAAE,gBAA2C;QAC7D,UAAU;QACV,GAAG;KACH,CAAC,CAAC;IACH,OAAO;QACN,oBAAoB;QACpB,gBAAgB;QAChB,aAAa;KACb,CAAC;AACH,CAAC","sourcesContent":["/**\n * Section runtime engine resolver (M7).\n *\n * Canonical home of `resolveRuntime`, `resolveToolsConfig`, and their\n * supporting helpers/types. As of M7 PR 7 the previous duplicates in\n * `packages/section-player/src/components/shared/section-player-runtime.ts`\n * have been deleted; section-player now consumes these helpers via\n * `@pie-players/pie-assessment-toolkit/runtime/internal`.\n *\n * What is NOT absorbed in this module:\n * - `resolvePlayerRuntime` stays in section-player because it depends on\n * `DEFAULT_PLAYER_DEFINITIONS` (which side-effect-imports the\n * item-player package). The toolkit core stays free of that\n * dependency by exposing a parametrized orchestrator —\n * `resolveSectionEngineRuntimeState` — that takes a `resolvePlayerRuntime`\n * callable. The section-player wrapper\n * (`resolveSectionPlayerRuntimeState` in\n * `packages/section-player/src/components/shared/section-player-host-runtime.ts`)\n * hands its local implementation in.\n *\n * The strict mirror rule (M5) and the `runtime.<key>` precedence rule\n * are preserved bit-for-bit; the per-key precedence test in\n * `engine-resolver.test.ts` is the guardrail.\n */\n\nimport type { LoaderConfig } from \"@pie-players/pie-players-shared/loader-config\";\nimport type {\n\tLoadingCompleteDetail,\n\tStageChangeDetail,\n} from \"@pie-players/pie-players-shared/pie\";\nimport type { FrameworkErrorModel } from \"../../services/framework-error.js\";\nimport type { ToolConfigStrictness } from \"../../services/tool-config-validation.js\";\nimport { parseToolList } from \"../../services/tools-config-normalizer.js\";\n\nexport const DEFAULT_ASSESSMENT_ID = \"section-demo-direct\";\nexport const DEFAULT_PLAYER_TYPE = \"iife\";\nexport const DEFAULT_LAZY_INIT = true;\nexport const DEFAULT_ISOLATION = \"inherit\";\nexport const DEFAULT_ENV = { mode: \"gather\", role: \"student\" } as Record<\n\tstring,\n\tunknown\n>;\n\nexport type PlayerOverrides = {\n\tloaderConfig?: LoaderConfig;\n\tloaderOptions?: Record<string, unknown>;\n\t[key: string]: unknown;\n};\n\nexport type FrameworkErrorHandler = (model: FrameworkErrorModel) => void;\nexport type StageChangeHandler = (detail: StageChangeDetail) => void;\nexport type LoadingCompleteHandler = (detail: LoadingCompleteDetail) => void;\n\n/**\n * Two-tier section runtime config (M5 strict mirror, post-trim).\n *\n * Mirror rule: `kebab-attribute ↔ camelCaseProp ↔ runtime.<sameCamelCaseKey>`.\n * `runtime.<key>` always wins over the equivalent prop/attribute.\n *\n * Documented exceptions (no runtime mirror, by design): identity\n * (`section-id`, `attempt-id`, `section`); layout-only shell knobs\n * (`show-toolbar`, `toolbar-position`, etc.); and layout-shell host\n * data (`policies`, `hooks`, `toolRegistry`, `*HostButtons`). Those\n * surfaces are layout-shell concerns; the runtime engine does not see\n * them. See section-player's ARCHITECTURE.md for the full policy.\n */\nexport type RuntimeConfig = {\n\tassessmentId?: string;\n\tplayerType?: string;\n\tplayer?: PlayerOverrides | null;\n\tlazyInit?: boolean;\n\ttools?: Record<string, unknown> | null;\n\ttoolContextResolvers?: Record<string, unknown> | null;\n\taccessibility?: Record<string, unknown> | null;\n\tcoordinator?: unknown;\n\tcreateSectionController?: unknown;\n\tisolation?: string;\n\tenv?: Record<string, unknown>;\n\ttoolConfigStrictness?: ToolConfigStrictness;\n\n\t// M3 mirror — canonical onFrameworkError handler.\n\tonFrameworkError?: FrameworkErrorHandler;\n\n\t// M5 mirror — `enabledTools` is the canonical tier-1 shorthand for\n\t// `tools.placement.section`; `resolveToolsConfig` reads it from\n\t// `runtime?.enabledTools` when present.\n\tenabledTools?: string;\n\n\t// M6 mirror — canonical stage-change callback. The DOM event\n\t// `pie-stage-change` remains the primary channel; this callback is\n\t// the convenience surface that mirrors the event one-to-one.\n\tonStageChange?: StageChangeHandler;\n\n\t// M6 mirror — canonical loading-complete callback. Mirrors the\n\t// `pie-loading-complete` DOM event, which the engine dispatches\n\t// once per cohort when every item has finished loading.\n\tonLoadingComplete?: LoadingCompleteHandler;\n};\n\nexport type RuntimeInputs = {\n\tassessmentId?: string;\n\tplayerType?: string;\n\tplayer?: PlayerOverrides | null;\n\tlazyInit?: boolean;\n\ttools?: Record<string, unknown> | null;\n\taccessibility?: Record<string, unknown> | null;\n\tcoordinator?: unknown;\n\tenv?: Record<string, unknown> | null;\n\ttoolConfigStrictness?: ToolConfigStrictness;\n\tonFrameworkError?: FrameworkErrorHandler;\n\tonStageChange?: StageChangeHandler;\n\tonLoadingComplete?: LoadingCompleteHandler;\n\truntime: RuntimeConfig | null;\n\tenabledTools: string;\n};\n\n/**\n * Pick the runtime-tier value when defined, otherwise the prop/attribute\n * value. The strict mirror rule means every tier-1 surface is resolved\n * with this single helper; per-feature special-casing is forbidden.\n */\nfunction pick<T>(\n\truntimeVal: T | undefined,\n\tattrVal: T | undefined,\n): T | undefined {\n\treturn runtimeVal !== undefined ? runtimeVal : attrVal;\n}\n\n/**\n * Resolve the canonical `onFrameworkError` handler from the two-tier\n * surface. Precedence (highest first): `runtime.onFrameworkError`,\n * then top-level `onFrameworkError`. Layout CEs and the kernel call\n * this so every entry point converges on the same handler.\n */\nexport function resolveOnFrameworkError(args: {\n\truntime: RuntimeConfig | null;\n\tonFrameworkError?: FrameworkErrorHandler;\n}): FrameworkErrorHandler | undefined {\n\tconst r = args.runtime ?? {};\n\tif (r.onFrameworkError !== undefined) return r.onFrameworkError;\n\treturn args.onFrameworkError;\n}\n\nexport function resolveToolsConfig(args: {\n\truntime: RuntimeConfig | null;\n\ttools: Record<string, unknown> | null;\n\tenabledTools: string;\n}) {\n\tconst runtimeTools = (args.runtime?.tools || args.tools || {}) as Record<\n\t\tstring,\n\t\tunknown\n\t>;\n\t// `runtime.enabledTools` is the canonical mirror; the kebab attribute is\n\t// the easy-tier alias. Per Decision B1, it merges into\n\t// `tools.placement.section`. The object form (`runtime.tools`) keeps\n\t// precedence over both — that lock lives in the merge below.\n\t//\n\t// The deprecated `item-toolbar-tools` / `passage-toolbar-tools`\n\t// per-region aliases were removed in the broad architecture review\n\t// compat sweep; hosts must populate `tools.placement.item` /\n\t// `tools.placement.passage` (object form) or\n\t// `runtime.tools.placement.{item,passage}` directly.\n\tconst effectiveEnabledTools =\n\t\tpick(args.runtime?.enabledTools, args.enabledTools) ?? \"\";\n\tconst sectionTools = parseToolList(effectiveEnabledTools);\n\tconst placement = (runtimeTools.placement || {}) as Record<string, unknown>;\n\tconst overlayToolsConfig = {\n\t\t...runtimeTools,\n\t\tplacement: {\n\t\t\t...placement,\n\t\t\t...(sectionTools.length > 0 ? { section: sectionTools } : {}),\n\t\t},\n\t};\n\t// Keep host-provided shape intact; framework-owned validation surfaces malformed config.\n\treturn overlayToolsConfig;\n}\n\nexport function resolveRuntime(args: {\n\tassessmentId: string;\n\tplayerType: string;\n\tplayer: PlayerOverrides | null;\n\tlazyInit: boolean;\n\taccessibility: Record<string, unknown> | null;\n\tcoordinator: unknown;\n\tenv: Record<string, unknown> | null;\n\truntime: RuntimeConfig | null;\n\teffectiveToolsConfig: unknown;\n\ttoolConfigStrictness?: ToolConfigStrictness;\n\tonFrameworkError?: FrameworkErrorHandler;\n\tonStageChange?: StageChangeHandler;\n\tonLoadingComplete?: LoadingCompleteHandler;\n}) {\n\tconst r = args.runtime || {};\n\tconst topLevelPlayer = (args.player || {}) as PlayerOverrides;\n\tconst runtimePlayer = (r.player || {}) as PlayerOverrides;\n\tconst mergedPlayerCandidate = {\n\t\t...topLevelPlayer,\n\t\t...runtimePlayer,\n\t\tloaderOptions: {\n\t\t\t...((topLevelPlayer.loaderOptions || {}) as Record<string, unknown>),\n\t\t\t...((runtimePlayer.loaderOptions || {}) as Record<string, unknown>),\n\t\t},\n\t\tloaderConfig: {\n\t\t\t...((topLevelPlayer.loaderConfig || {}) as Record<string, unknown>),\n\t\t\t...((runtimePlayer.loaderConfig || {}) as Record<string, unknown>),\n\t\t},\n\t};\n\tconst mergedPlayer =\n\t\tObject.keys(mergedPlayerCandidate).length > 0\n\t\t\t? mergedPlayerCandidate\n\t\t\t: null;\n\treturn {\n\t\t...r,\n\t\tassessmentId: pick(r.assessmentId, args.assessmentId),\n\t\tplayerType: pick(r.playerType, args.playerType),\n\t\tplayer: mergedPlayer,\n\t\tlazyInit: pick(r.lazyInit, args.lazyInit),\n\t\taccessibility: pick(r.accessibility, args.accessibility),\n\t\tcoordinator: pick(r.coordinator, args.coordinator),\n\t\tcreateSectionController: r.createSectionController,\n\t\tisolation: r.isolation ?? DEFAULT_ISOLATION,\n\t\tenv: pick(r.env, args.env) ?? DEFAULT_ENV,\n\t\ttoolConfigStrictness:\n\t\t\tpick(r.toolConfigStrictness, args.toolConfigStrictness) ?? \"error\",\n\n\t\t// M3 mirror absorbed via the shared helper so every layout CE wires\n\t\t// `onFrameworkError` identically.\n\t\tonFrameworkError: resolveOnFrameworkError({\n\t\t\truntime: args.runtime,\n\t\t\tonFrameworkError: args.onFrameworkError,\n\t\t}),\n\n\t\t// M6 mirror — `onStageChange` follows the same precedence as every\n\t\t// other tier-1 surface: `runtime.onStageChange` wins over the\n\t\t// top-level prop.\n\t\tonStageChange: pick(r.onStageChange, args.onStageChange),\n\n\t\t// M6 mirror — `onLoadingComplete` follows the same precedence\n\t\t// rule.\n\t\tonLoadingComplete: pick(r.onLoadingComplete, args.onLoadingComplete),\n\n\t\ttools: args.effectiveToolsConfig,\n\t};\n}\n\n/**\n * Effective runtime returned by `resolveRuntime`. The shape is exposed\n * as `unknown` at the public boundary because consumers spread it into\n * arbitrary host props; downstream call sites narrow with the specific\n * keys they need.\n */\nexport type EffectiveRuntime = ReturnType<typeof resolveRuntime>;\n\n/**\n * Engine-side orchestrator that mirrors the legacy\n * `resolveSectionPlayerRuntimeState` from section-player but takes\n * `resolvePlayerRuntime` as an injected callable so the toolkit core\n * stays free of host-coupled defaults (`DEFAULT_PLAYER_DEFINITIONS`).\n *\n * The legacy section-player wrapper passes its local `resolvePlayerRuntime`\n * here in M7 PR 5 when the kernel switches onto the engine.\n */\nexport function resolveSectionEngineRuntimeState<P>(\n\targs: RuntimeInputs,\n\tdeps: {\n\t\tresolvePlayerRuntime: (resolverArgs: {\n\t\t\teffectiveRuntime: Record<string, unknown>;\n\t\t\tplayerType: string;\n\t\t\tenv: Record<string, unknown> | null;\n\t\t}) => P;\n\t},\n): {\n\teffectiveToolsConfig: unknown;\n\teffectiveRuntime: EffectiveRuntime;\n\tplayerRuntime: P;\n} {\n\tconst assessmentId = args.assessmentId ?? DEFAULT_ASSESSMENT_ID;\n\tconst playerType = args.playerType ?? DEFAULT_PLAYER_TYPE;\n\tconst player = args.player ?? null;\n\tconst lazyInit = args.lazyInit ?? DEFAULT_LAZY_INIT;\n\tconst accessibility = args.accessibility ?? null;\n\tconst coordinator = args.coordinator ?? null;\n\tconst env = args.env ?? null;\n\tconst tools = args.tools ?? null;\n\n\tconst effectiveToolsConfig = resolveToolsConfig({\n\t\truntime: args.runtime,\n\t\ttools,\n\t\tenabledTools: args.enabledTools,\n\t});\n\tconst effectiveRuntime = resolveRuntime({\n\t\tassessmentId,\n\t\tplayerType,\n\t\tplayer,\n\t\tlazyInit,\n\t\taccessibility,\n\t\tcoordinator,\n\t\tenv,\n\t\truntime: args.runtime,\n\t\teffectiveToolsConfig,\n\t\ttoolConfigStrictness: args.toolConfigStrictness,\n\t\tonFrameworkError: args.onFrameworkError,\n\t\tonStageChange: args.onStageChange,\n\t\tonLoadingComplete: args.onLoadingComplete,\n\t});\n\tconst playerRuntime = deps.resolvePlayerRuntime({\n\t\teffectiveRuntime: effectiveRuntime as Record<string, unknown>,\n\t\tplayerType,\n\t\tenv,\n\t});\n\treturn {\n\t\teffectiveToolsConfig,\n\t\teffectiveRuntime,\n\t\tplayerRuntime,\n\t};\n}\n"]}
@@ -16,4 +16,3 @@
16
16
  import type { Stage } from "@pie-players/pie-players-shared/pie";
17
17
  import type { SectionEnginePhase } from "./engine-state.js";
18
18
  export declare function phaseToStage(phase: SectionEnginePhase): Stage | null;
19
- //# sourceMappingURL=engine-stage-derivation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-stage-derivation.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-stage-derivation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,UAAU,YAAY,CAAC,KAAyB;IACrD,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,MAAM;YACV,OAAO,IAAI,CAAC;QACb,KAAK,iBAAiB;YACrB,OAAO,UAAU,CAAC;QACnB,KAAK,cAAc;YAClB,OAAO,cAAc,CAAC;QACvB,KAAK,aAAa;YACjB,OAAO,aAAa,CAAC;QACtB,KAAK,UAAU;YACd,OAAO,UAAU,CAAC;IACpB,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"engine-stage-derivation.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-stage-derivation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,UAAU,YAAY,CAAC,KAAyB;IACrD,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,MAAM;YACV,OAAO,IAAI,CAAC;QACb,KAAK,iBAAiB;YACrB,OAAO,UAAU,CAAC;QACnB,KAAK,cAAc;YAClB,OAAO,cAAc,CAAC;QACvB,KAAK,aAAa;YACjB,OAAO,aAAa,CAAC;QACtB,KAAK,UAAU;YACd,OAAO,UAAU,CAAC;IACpB,CAAC;AACF,CAAC","sourcesContent":["/**\n * Stage derivation for the section runtime engine (M7).\n *\n * Maps the FSM phase onto the canonical M6 stage vocabulary\n * (`composed`, `engine-ready`, `interactive`, `disposed`). The phase\n * `idle` is the engine's \"no cohort yet\" state and has no stage; it\n * returns `null`.\n *\n * This module exists as a one-line indirection because:\n * - The adapter uses it to guard `pie-stage-change` emit calls.\n * - The transition uses it (via the pure helper below) to decide\n * when to emit `stage-change` outputs as the phase advances.\n * - Future shape-specific stages (e.g. layout-only `paginated`) can\n * be wired in here without rewriting callers.\n */\n\nimport type { Stage } from \"@pie-players/pie-players-shared/pie\";\nimport type { SectionEnginePhase } from \"./engine-state.js\";\n\nexport function phaseToStage(phase: SectionEnginePhase): Stage | null {\n\tswitch (phase) {\n\t\tcase \"idle\":\n\t\t\treturn null;\n\t\tcase \"booting-section\":\n\t\t\treturn \"composed\";\n\t\tcase \"engine-ready\":\n\t\t\treturn \"engine-ready\";\n\t\tcase \"interactive\":\n\t\t\treturn \"interactive\";\n\t\tcase \"disposed\":\n\t\t\treturn \"disposed\";\n\t}\n}\n"]}
@@ -80,4 +80,3 @@ export type SectionEngineState = {
80
80
  * default by reference.
81
81
  */
82
82
  export declare function createInitialEngineState(): SectionEngineState;
83
- //# sourceMappingURL=engine-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-state.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAuEH;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACvC,OAAO;QACN,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,IAAI;QACZ,kBAAkB,EAAE,KAAK;QACzB,gBAAgB,EAAE;YACjB,YAAY,EAAE,KAAK;YACnB,gBAAgB,EAAE,KAAK;YACvB,kBAAkB,EAAE,KAAK;YACzB,YAAY,EAAE,KAAK;SACnB;QACD,gBAAgB,EAAE,IAAI;QACtB,oBAAoB,EAAE,IAAI;QAC1B,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,SAAS,EAAE,CAAC;QACZ,WAAW,EAAE,CAAC;KACd,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"engine-state.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAuEH;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACvC,OAAO;QACN,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,IAAI;QACZ,kBAAkB,EAAE,KAAK;QACzB,gBAAgB,EAAE;YACjB,YAAY,EAAE,KAAK;YACnB,gBAAgB,EAAE,KAAK;YACvB,kBAAkB,EAAE,KAAK;YACzB,YAAY,EAAE,KAAK;SACnB;QACD,gBAAgB,EAAE,IAAI;QACtB,oBAAoB,EAAE,IAAI;QAC1B,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,SAAS,EAAE,CAAC;QACZ,WAAW,EAAE,CAAC;KACd,CAAC;AACH,CAAC","sourcesContent":["/**\n * Section runtime engine state (M7 — Variant C, layered core).\n *\n * The state object is the single source of truth for stage, cohort,\n * readiness signals, and the resolved coordinator/controller handles\n * across one engine instance. The transition function in\n * `engine-transition.ts` is the only legal mutator; the adapter (M7\n * PR 2) reads the state via `SectionEngineCore.getState()` and emits\n * the bundled `SectionEngineOutput[]` to its bridges.\n *\n * Phases (the FSM). Adjustment A2 of the M7 implementation plan locks\n * this list to four phases that map 1:1 onto the M6 canonical stages:\n *\n * `idle` → no cohort yet (before `initialize`).\n * `booting-section` → cohort known, controller resolution pending. Maps to stage `composed`.\n * `engine-ready` → controller resolved. Maps to stage `engine-ready`.\n * `interactive` → readiness gate satisfied. Maps to stage `interactive`.\n * `disposed` → engine torn down. Maps to stage `disposed`.\n *\n * `loading-complete` is intentionally **not** an FSM phase — it is a\n * `SectionEngineOutput` emitted from the `interactive` phase when the\n * readiness signals satisfy `allLoadingComplete`. See\n * `engine-output.ts` for the output shape and the implementation\n * plan's Adjustment A2 fence.\n */\n\nimport type { CohortKey } from \"./cohort.js\";\nimport type { EffectiveRuntime } from \"./engine-resolver.js\";\nimport type { EngineReadinessSignals } from \"./engine-readiness.js\";\nimport type { FrameworkErrorModel } from \"../../services/framework-error.js\";\n\nexport type SectionEnginePhase =\n\t| \"idle\"\n\t| \"booting-section\"\n\t| \"engine-ready\"\n\t| \"interactive\"\n\t| \"disposed\";\n\nexport type SectionEngineState = {\n\t/** Current FSM phase. The single source of truth for stage derivation. */\n\tphase: SectionEnginePhase;\n\n\t/**\n\t * Active cohort, or `null` when the engine is `idle` or `disposed`.\n\t * `phase === \"idle\"` always implies `cohort === null`. A non-idle,\n\t * non-disposed phase always has a cohort.\n\t */\n\tcohort: CohortKey | null;\n\n\t/**\n\t * Whether the host has reported the section controller is resolved.\n\t * Latched by the `section-controller-resolved` input; the\n\t * transition uses it (along with `phase >= booting-section`) to\n\t * advance into `engine-ready`.\n\t */\n\tcontrollerResolved: boolean;\n\n\t/**\n\t * Readiness signal snapshot. Updated by `update-readiness-signals`\n\t * inputs from the host (kernel) — the engine itself does not\n\t * compute these from scratch in PR 1. Strict-mode gating is\n\t * applied at derivation time via `createReadinessDetail`, not by\n\t * mutating the signals.\n\t */\n\treadinessSignals: EngineReadinessSignals;\n\n\t/** Last resolved effective runtime (output of `resolveRuntime`). */\n\teffectiveRuntime: EffectiveRuntime | null;\n\n\t/** Last resolved tools config. */\n\teffectiveToolsConfig: unknown;\n\n\t/**\n\t * `true` once the engine has emitted `loading-complete` for the\n\t * current cohort. Re-armed on cohort change. The single-shot\n\t * semantics of the canonical `pie-loading-complete` event are\n\t * preserved by gating emission on this flag in the transition.\n\t */\n\tloadingCompleteEmitted: boolean;\n\n\t/**\n\t * Most recent framework error, if any. The engine routes errors\n\t * through outputs, not through state — this field is kept so\n\t * subscribers asking for the latest snapshot (e.g. error banners)\n\t * can read it without replaying the output stream.\n\t */\n\tlastFrameworkError: FrameworkErrorModel | null;\n\n\t/** Number of items the host has registered for the current cohort. */\n\titemCount: number;\n\n\t/** Number of items reported as loaded. */\n\tloadedCount: number;\n};\n\n/**\n * Initial state. Kept as a function so callers cannot mutate a shared\n * default by reference.\n */\nexport function createInitialEngineState(): SectionEngineState {\n\treturn {\n\t\tphase: \"idle\",\n\t\tcohort: null,\n\t\tcontrollerResolved: false,\n\t\treadinessSignals: {\n\t\t\tsectionReady: false,\n\t\t\tinteractionReady: false,\n\t\t\tallLoadingComplete: false,\n\t\t\truntimeError: false,\n\t\t},\n\t\teffectiveRuntime: null,\n\t\teffectiveToolsConfig: null,\n\t\tloadingCompleteEmitted: false,\n\t\tlastFrameworkError: null,\n\t\titemCount: 0,\n\t\tloadedCount: 0,\n\t};\n}\n"]}
@@ -46,4 +46,3 @@ export interface TransitionResult {
46
46
  * core stays safe by design).
47
47
  */
48
48
  export declare function transition(state: SectionEngineState, input: SectionEngineInput): TransitionResult;
49
- //# sourceMappingURL=engine-transition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-transition.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAG3D,OAAO,EACN,qBAAqB,GAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACN,wBAAwB,GAGxB,MAAM,mBAAmB,CAAC;AAO3B,SAAS,eAAe,CACvB,OAA8B,EAC9B,KAAyB,EACzB,MAAwB,EACxB,SAA2C,SAAS;IAEpD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAMpB;IACA,MAAM,IAAI,GAAuB;QAChC,GAAG,wBAAwB,EAAE;QAC7B,KAAK,EAAE,iBAAiB;QACxB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;QAC/C,SAAS,EAAE,IAAI,CAAC,SAAS;KACzB,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AAiB,CAAC,CAAC,CAAC;YACxB,OAAO;gBACN,KAAK,EAAE;oBACN,GAAG,KAAK;oBACR,kBAAkB,EAAE,KAAK,CAAC,KAAK;oBAC/B,gBAAgB,EAAE;wBACjB,GAAG,KAAK,CAAC,gBAAgB;wBACzB,YAAY,EAAE,IAAI;qBAClB;iBACD;gBACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;aAC1D,CAAC;QACH,CAAC;QAED,KAAK,SAAS,CAAC,CAAC,CAAC;YAChB,IAAI,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAC/B,CAAC;YACD,MAAM,OAAO,GAA0B,EAAE,CAAC;YAC1C,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;gBAC5B,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC;YACD,OAAO;gBACN,KAAK,EAAE;oBACN,GAAG,KAAK;oBACR,KAAK,EAAE,UAAU;iBACjB;gBACD,OAAO;aACP,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,UAAU,GAAU,KAAK,CAAC;YAChC,KAAK,UAAU,CAAC;YAChB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"engine-transition.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAG3D,OAAO,EACN,qBAAqB,GAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE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AC;gBAC5B,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC;YACD,OAAO;gBACN,KAAK,EAAE;oBACN,GAAG,KAAK;oBACR,KAAK,EAAE,UAAU;iBACjB;gBACD,OAAO;aACP,CAAC;QACH,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,UAAU,GAAU,KAAK,CAAC;YAChC,KAAK,UAAU,CAAC;YAChB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAC/B,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["/**\n * Pure transition function for the section runtime engine (M7 — Variant\n * C, layered core).\n *\n * `transition(state, input)` is total over `(state, input)` pairs and\n * returns:\n * - the next `SectionEngineState` (immutable; the input state object\n * is never mutated);\n * - the ordered list of `SectionEngineOutput`s the adapter must\n * dispatch (DOM events, framework-error fan-out, etc.).\n *\n * The function imports nothing from Svelte, the DOM, or the\n * coordinator. The `core/` constraint is enforced by the per-PR audit\n * step in the M7 implementation plan.\n *\n * Phase machine (per `engine-state.ts`):\n * idle → booting-section → engine-ready → interactive → disposed\n * (cohort-change rolls back to booting-section for the new cohort\n * after emitting `disposed` for the outgoing cohort)\n *\n * Output ordering invariants:\n * 1. `stage-change` for stage advancement fires before any\n * `loading-complete` triggered by the same input.\n * 2. `loading-complete` fires once per cohort, gated on\n * `state.loadingCompleteEmitted`.\n * 3. `framework-error` outputs are independent of the stage chain\n * and do not move the phase.\n *\n * The deprecated readiness output kinds (`readiness-change`,\n * `interaction-ready`, `ready`) and their DOM-event bridge were\n * removed in the broad architecture review compat sweep. Hosts that\n * need the readiness detail read it via the kernel's `selectReadiness`\n * / `getSnapshot` selectors or via `SectionEngineCore.getState()`.\n */\n\nimport { cohortsEqual, type CohortKey } from \"./cohort.js\";\nimport type { SectionEngineInput } from \"./engine-input.js\";\nimport type { SectionEngineOutput } from \"./engine-output.js\";\nimport {\n\tcreateReadinessDetail,\n\ttype EngineReadinessSignals,\n} from \"./engine-readiness.js\";\nimport { phaseToStage } from \"./engine-stage-derivation.js\";\nimport {\n\tcreateInitialEngineState,\n\ttype SectionEnginePhase,\n\ttype SectionEngineState,\n} from \"./engine-state.js\";\n\nexport interface TransitionResult {\n\tstate: SectionEngineState;\n\toutputs: SectionEngineOutput[];\n}\n\nfunction emitStageChange(\n\toutputs: SectionEngineOutput[],\n\tphase: SectionEnginePhase,\n\tcohort: CohortKey | null,\n\tstatus: \"entered\" | \"skipped\" | \"failed\" = \"entered\",\n): void {\n\tconst stage = phaseToStage(phase);\n\tif (!stage) return;\n\toutputs.push({ kind: \"stage-change\", stage, status, cohort });\n}\n\n/**\n * Transition the engine after `initialize` / `cohort-change`. Sets\n * the new cohort, resets latches, stores the resolved runtime/tools,\n * and emits the `composed` stage.\n */\nfunction startCohort(args: {\n\tstate: SectionEngineState;\n\tcohort: CohortKey;\n\teffectiveRuntime: SectionEngineState[\"effectiveRuntime\"];\n\teffectiveToolsConfig: unknown;\n\titemCount: number;\n}): { state: SectionEngineState; outputs: SectionEngineOutput[] } {\n\tconst next: SectionEngineState = {\n\t\t...createInitialEngineState(),\n\t\tphase: \"booting-section\",\n\t\tcohort: args.cohort,\n\t\teffectiveRuntime: args.effectiveRuntime,\n\t\teffectiveToolsConfig: args.effectiveToolsConfig,\n\t\titemCount: args.itemCount,\n\t};\n\tconst outputs: SectionEngineOutput[] = [];\n\temitStageChange(outputs, \"booting-section\", args.cohort);\n\treturn { state: next, outputs };\n}\n\n/**\n * Apply a readiness update: store new signals, derive the detail in\n * the requested mode, advance the phase to `interactive` when gated,\n * and emit `loading-complete` once per cohort.\n */\nfunction applyReadinessUpdate(\n\tstate: SectionEngineState,\n\targs: {\n\t\tsignals: EngineReadinessSignals;\n\t\tmode: \"progressive\" | \"strict\";\n\t\tloadedCount: number;\n\t\titemCount: number;\n\t},\n): TransitionResult {\n\tif (state.phase === \"idle\" || state.phase === \"disposed\") {\n\t\t// No cohort to update; ignore.\n\t\treturn { state, outputs: [] };\n\t}\n\n\tconst detail = createReadinessDetail({\n\t\tmode: args.mode,\n\t\tsignals: args.signals,\n\t});\n\tconst outputs: SectionEngineOutput[] = [];\n\n\tlet phase = state.phase;\n\tlet loadingCompleteEmitted = state.loadingCompleteEmitted;\n\n\t// Stage advancement: engine-ready → interactive when readiness\n\t// satisfies `interactionReady` (mode-aware via `createReadinessDetail`).\n\tif (phase === \"engine-ready\" && detail.interactionReady) {\n\t\tphase = \"interactive\";\n\t\temitStageChange(outputs, phase, state.cohort);\n\t}\n\n\t// Canonical `loading-complete` emission. One-shot per cohort, gated\n\t// on the readiness signals indicating every item has finished\n\t// loading.\n\tif (\n\t\tdetail.allLoadingComplete &&\n\t\tstate.cohort &&\n\t\t!loadingCompleteEmitted\n\t) {\n\t\tloadingCompleteEmitted = true;\n\t\toutputs.push({\n\t\t\tkind: \"loading-complete\",\n\t\t\tcohort: state.cohort,\n\t\t\titemCount: args.itemCount,\n\t\t\tloadedCount: args.loadedCount,\n\t\t});\n\t}\n\n\tconst nextState: SectionEngineState = {\n\t\t...state,\n\t\tphase,\n\t\treadinessSignals: args.signals,\n\t\tloadedCount: args.loadedCount,\n\t\titemCount: args.itemCount,\n\t\tloadingCompleteEmitted,\n\t};\n\treturn { state: nextState, outputs };\n}\n\n/**\n * Pure transition. Total over `(state, input)`; never mutates inputs;\n * never throws. Unhandled inputs after `disposed` fall through to a\n * no-op (the adapter is responsible for not feeding them in, but the\n * core stays safe by design).\n */\nexport function transition(\n\tstate: SectionEngineState,\n\tinput: SectionEngineInput,\n): TransitionResult {\n\tswitch (input.kind) {\n\t\tcase \"initialize\": {\n\t\t\tif (state.phase === \"disposed\") {\n\t\t\t\t// The engine has been disposed; ignore.\n\t\t\t\treturn { state, outputs: [] };\n\t\t\t}\n\t\t\tif (state.phase !== \"idle\") {\n\t\t\t\t// Already initialized. Treat as `update-runtime` for the\n\t\t\t\t// current cohort if the cohort matches; otherwise treat as\n\t\t\t\t// a `cohort-change`.\n\t\t\t\tif (cohortsEqual(state.cohort, input.cohort)) {\n\t\t\t\t\treturn transition(state, {\n\t\t\t\t\t\tkind: \"update-runtime\",\n\t\t\t\t\t\teffectiveRuntime: input.effectiveRuntime,\n\t\t\t\t\t\teffectiveToolsConfig: input.effectiveToolsConfig,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn transition(state, {\n\t\t\t\t\tkind: \"cohort-change\",\n\t\t\t\t\tcohort: input.cohort,\n\t\t\t\t\teffectiveRuntime: input.effectiveRuntime,\n\t\t\t\t\teffectiveToolsConfig: input.effectiveToolsConfig,\n\t\t\t\t\titemCount: input.itemCount,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn startCohort({\n\t\t\t\tstate,\n\t\t\t\tcohort: input.cohort,\n\t\t\t\teffectiveRuntime: input.effectiveRuntime,\n\t\t\t\teffectiveToolsConfig: input.effectiveToolsConfig,\n\t\t\t\titemCount: input.itemCount,\n\t\t\t});\n\t\t}\n\n\t\tcase \"update-runtime\": {\n\t\t\tif (state.phase === \"idle\" || state.phase === \"disposed\") {\n\t\t\t\treturn { state, outputs: [] };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstate: {\n\t\t\t\t\t...state,\n\t\t\t\t\teffectiveRuntime: input.effectiveRuntime,\n\t\t\t\t\teffectiveToolsConfig: input.effectiveToolsConfig,\n\t\t\t\t},\n\t\t\t\toutputs: [],\n\t\t\t};\n\t\t}\n\n\t\tcase \"cohort-change\": {\n\t\t\tif (state.phase === \"disposed\") {\n\t\t\t\treturn { state, outputs: [] };\n\t\t\t}\n\t\t\tif (cohortsEqual(state.cohort, input.cohort)) {\n\t\t\t\t// No-op cohort change; fall back to a runtime update.\n\t\t\t\treturn transition(state, {\n\t\t\t\t\tkind: \"update-runtime\",\n\t\t\t\t\teffectiveRuntime: input.effectiveRuntime,\n\t\t\t\t\teffectiveToolsConfig: input.effectiveToolsConfig,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst outputs: SectionEngineOutput[] = [];\n\t\t\tif (state.phase !== \"idle\") {\n\t\t\t\t// Emit `disposed` for the outgoing cohort before we wipe state.\n\t\t\t\toutputs.push({\n\t\t\t\t\tkind: \"stage-change\",\n\t\t\t\t\tstage: \"disposed\",\n\t\t\t\t\tstatus: \"entered\",\n\t\t\t\t\tcohort: state.cohort,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst started = startCohort({\n\t\t\t\tstate,\n\t\t\t\tcohort: input.cohort,\n\t\t\t\teffectiveRuntime: input.effectiveRuntime,\n\t\t\t\teffectiveToolsConfig: input.effectiveToolsConfig,\n\t\t\t\titemCount: input.itemCount,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tstate: started.state,\n\t\t\t\toutputs: [...outputs, ...started.outputs],\n\t\t\t};\n\t\t}\n\n\t\tcase \"section-controller-resolved\": {\n\t\t\tif (state.phase !== \"booting-section\") {\n\t\t\t\t// Either too early (idle), too late (interactive / disposed),\n\t\t\t\t// or a duplicate notification; the FSM is monotonic.\n\t\t\t\treturn {\n\t\t\t\t\tstate: { ...state, controllerResolved: true },\n\t\t\t\t\toutputs: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst outputs: SectionEngineOutput[] = [];\n\t\t\temitStageChange(outputs, \"engine-ready\", state.cohort);\n\t\t\treturn {\n\t\t\t\tstate: {\n\t\t\t\t\t...state,\n\t\t\t\t\tphase: \"engine-ready\",\n\t\t\t\t\tcontrollerResolved: true,\n\t\t\t\t},\n\t\t\t\toutputs,\n\t\t\t};\n\t\t}\n\n\t\tcase \"update-readiness-signals\": {\n\t\t\treturn applyReadinessUpdate(state, {\n\t\t\t\tsignals: input.signals,\n\t\t\t\tmode: input.mode,\n\t\t\t\tloadedCount: input.loadedCount,\n\t\t\t\titemCount: input.itemCount,\n\t\t\t});\n\t\t}\n\n\t\tcase \"framework-error\": {\n\t\t\treturn {\n\t\t\t\tstate: {\n\t\t\t\t\t...state,\n\t\t\t\t\tlastFrameworkError: input.error,\n\t\t\t\t\treadinessSignals: {\n\t\t\t\t\t\t...state.readinessSignals,\n\t\t\t\t\t\truntimeError: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toutputs: [{ kind: \"framework-error\", error: input.error }],\n\t\t\t};\n\t\t}\n\n\t\tcase \"dispose\": {\n\t\t\tif (state.phase === \"disposed\") {\n\t\t\t\treturn { state, outputs: [] };\n\t\t\t}\n\t\t\tconst outputs: SectionEngineOutput[] = [];\n\t\t\tif (state.phase !== \"idle\") {\n\t\t\t\temitStageChange(outputs, \"disposed\", state.cohort);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstate: {\n\t\t\t\t\t...state,\n\t\t\t\t\tphase: \"disposed\",\n\t\t\t\t},\n\t\t\t\toutputs,\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\tconst exhaustive: never = input;\n\t\t\tvoid exhaustive;\n\t\t\treturn { state, outputs: [] };\n\t\t}\n\t}\n}\n"]}
@@ -37,4 +37,3 @@ export declare const SECTION_RUNTIME_ENGINE_KEY: unique symbol;
37
37
  * class directly.
38
38
  */
39
39
  export type SectionRuntimeEngineContext = SectionRuntimeEngine;
40
- //# sourceMappingURL=engine-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-context.js","sourceRoot":"","sources":["../../src/runtime/engine-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAkB,MAAM,CAC9D,qCAAqC,CACrC,CAAC"}
1
+ {"version":3,"file":"engine-context.js","sourceRoot":"","sources":["../../src/runtime/engine-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAkB,MAAM,CAC9D,qCAAqC,CACrC,CAAC","sourcesContent":["/**\n * Svelte context key for the section runtime engine (M7 PR 5).\n *\n * Components inside a section player layout consume the engine through\n * Svelte's native `getContext(SECTION_RUNTIME_ENGINE_KEY)`. The kernel\n * (`SectionPlayerLayoutKernel.svelte`) is the canonical provider — it\n * constructs the engine, attaches it to the layout CE host, and exposes\n * it to descendants via `setContext(SECTION_RUNTIME_ENGINE_KEY, engine)`.\n *\n * The contract is one-directional:\n * - Provider: the component that owns engine lifetime (kernel today;\n * in M7 PR 6 the toolkit CE will fall back to constructing its own\n * engine when no upstream provider is present).\n * - Consumers: any descendant Svelte component that needs to read\n * state, subscribe to outputs, or feed inputs (e.g. the toolkit CE\n * reaching the engine through the wrapping kernel).\n *\n * The key is a `Symbol` so it cannot collide with userland context keys\n * and so descendants are forced to import this module rather than\n * guess a string id.\n *\n * **Stability.** This export is part of the stable runtime/engine\n * surface; renaming or replacing the symbol is a major breaking\n * change. Adding adjacent context keys (e.g. for dedicated read-only\n * snapshots) is allowed.\n */\n\nimport type { SectionRuntimeEngine } from \"./SectionRuntimeEngine.js\";\n\n/**\n * Svelte context key under which a `SectionRuntimeEngine` instance is\n * provided to descendants.\n */\nexport const SECTION_RUNTIME_ENGINE_KEY: unique symbol = Symbol(\n\t\"@pie-players/section-runtime-engine\",\n);\n\n/**\n * Type-level alias for the value stored under\n * `SECTION_RUNTIME_ENGINE_KEY`. Exposed as a separate alias so\n * consumers can spell the type without importing the implementing\n * class directly.\n */\nexport type SectionRuntimeEngineContext = SectionRuntimeEngine;\n"]}
@@ -21,4 +21,3 @@
21
21
  export { SectionRuntimeEngine, type SectionRuntimeEngineHostArgs, } from "./SectionRuntimeEngine.js";
22
22
  export { SECTION_RUNTIME_ENGINE_KEY, type SectionRuntimeEngineContext, } from "./engine-context.js";
23
23
  export { sectionRuntimeEngineHostContext, connectSectionRuntimeEngineHostContext, type SectionRuntimeEngineHostContextValue, type SectionRuntimeEngineHostContextListener, } from "./section-runtime-engine-host-context.js";
24
- //# sourceMappingURL=engine.d.ts.map