@pie-players/pie-assessment-toolkit 0.3.30 → 0.3.32

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 (179) hide show
  1. package/README.md +289 -5
  2. package/dist/components/ItemToolBar.custom-element.js +165 -92
  3. package/dist/components/PieAssessmentToolkit.custom-element.js +604 -107
  4. package/dist/components/SectionToolBar.custom-element.js +0 -36
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/policy/core/PolicySource.d.ts +64 -0
  9. package/dist/policy/core/PolicySource.d.ts.map +1 -0
  10. package/dist/policy/core/PolicySource.js +17 -0
  11. package/dist/policy/core/PolicySource.js.map +1 -0
  12. package/dist/policy/core/ToolPolicyEngine.d.ts +123 -0
  13. package/dist/policy/core/ToolPolicyEngine.d.ts.map +1 -0
  14. package/dist/policy/core/ToolPolicyEngine.js +217 -0
  15. package/dist/policy/core/ToolPolicyEngine.js.map +1 -0
  16. package/dist/policy/core/compose-decision.d.ts +37 -0
  17. package/dist/policy/core/compose-decision.d.ts.map +1 -0
  18. package/dist/policy/core/compose-decision.js +332 -0
  19. package/dist/policy/core/compose-decision.js.map +1 -0
  20. package/dist/policy/core/decision-types.d.ts +142 -0
  21. package/dist/policy/core/decision-types.d.ts.map +1 -0
  22. package/dist/policy/core/decision-types.js +13 -0
  23. package/dist/policy/core/decision-types.js.map +1 -0
  24. package/dist/policy/core/engine-context.d.ts +30 -0
  25. package/dist/policy/core/engine-context.d.ts.map +1 -0
  26. package/dist/policy/core/engine-context.js +28 -0
  27. package/dist/policy/core/engine-context.js.map +1 -0
  28. package/dist/policy/core/policy-source-tag.d.ts +32 -0
  29. package/dist/policy/core/policy-source-tag.d.ts.map +1 -0
  30. package/dist/policy/core/policy-source-tag.js +29 -0
  31. package/dist/policy/core/policy-source-tag.js.map +1 -0
  32. package/dist/policy/core/provenance.d.ts +163 -0
  33. package/dist/policy/core/provenance.d.ts.map +1 -0
  34. package/dist/policy/core/provenance.js +232 -0
  35. package/dist/policy/core/provenance.js.map +1 -0
  36. package/dist/policy/core/qti-inputs.d.ts +67 -0
  37. package/dist/policy/core/qti-inputs.d.ts.map +1 -0
  38. package/dist/policy/core/qti-inputs.js +139 -0
  39. package/dist/policy/core/qti-inputs.js.map +1 -0
  40. package/dist/policy/engine.d.ts +28 -0
  41. package/dist/policy/engine.d.ts.map +1 -0
  42. package/dist/policy/engine.js +24 -0
  43. package/dist/policy/engine.js.map +1 -0
  44. package/dist/policy/internal.d.ts +26 -0
  45. package/dist/policy/internal.d.ts.map +1 -0
  46. package/dist/policy/internal.js +26 -0
  47. package/dist/policy/internal.js.map +1 -0
  48. package/dist/policy/sources/QtiPolicySource.d.ts +146 -0
  49. package/dist/policy/sources/QtiPolicySource.d.ts.map +1 -0
  50. package/dist/policy/sources/QtiPolicySource.js +270 -0
  51. package/dist/policy/sources/QtiPolicySource.js.map +1 -0
  52. package/dist/runtime/SectionRuntimeEngine.d.ts +145 -0
  53. package/dist/runtime/SectionRuntimeEngine.d.ts.map +1 -1
  54. package/dist/runtime/SectionRuntimeEngine.js +164 -3
  55. package/dist/runtime/SectionRuntimeEngine.js.map +1 -1
  56. package/dist/runtime/adapter/SectionEngineAdapter.d.ts +144 -0
  57. package/dist/runtime/adapter/SectionEngineAdapter.d.ts.map +1 -0
  58. package/dist/runtime/adapter/SectionEngineAdapter.js +183 -0
  59. package/dist/runtime/adapter/SectionEngineAdapter.js.map +1 -0
  60. package/dist/runtime/adapter/coordinator-bridge.d.ts +93 -0
  61. package/dist/runtime/adapter/coordinator-bridge.d.ts.map +1 -0
  62. package/dist/runtime/adapter/coordinator-bridge.js +127 -0
  63. package/dist/runtime/adapter/coordinator-bridge.js.map +1 -0
  64. package/dist/runtime/adapter/dom-event-bridge.d.ts +63 -0
  65. package/dist/runtime/adapter/dom-event-bridge.d.ts.map +1 -0
  66. package/dist/runtime/adapter/dom-event-bridge.js +95 -0
  67. package/dist/runtime/adapter/dom-event-bridge.js.map +1 -0
  68. package/dist/runtime/adapter/framework-error-bridge.d.ts +37 -0
  69. package/dist/runtime/adapter/framework-error-bridge.d.ts.map +1 -0
  70. package/dist/runtime/adapter/framework-error-bridge.js +47 -0
  71. package/dist/runtime/adapter/framework-error-bridge.js.map +1 -0
  72. package/dist/runtime/adapter/instrumentation-bridge.d.ts +32 -0
  73. package/dist/runtime/adapter/instrumentation-bridge.d.ts.map +1 -0
  74. package/dist/runtime/adapter/instrumentation-bridge.js +39 -0
  75. package/dist/runtime/adapter/instrumentation-bridge.js.map +1 -0
  76. package/dist/runtime/adapter/subscriber-fanout.d.ts +35 -0
  77. package/dist/runtime/adapter/subscriber-fanout.d.ts.map +1 -0
  78. package/dist/runtime/adapter/subscriber-fanout.js +60 -0
  79. package/dist/runtime/adapter/subscriber-fanout.js.map +1 -0
  80. package/dist/runtime/core/SectionEngineCore.d.ts +52 -0
  81. package/dist/runtime/core/SectionEngineCore.d.ts.map +1 -0
  82. package/dist/runtime/core/SectionEngineCore.js +81 -0
  83. package/dist/runtime/core/SectionEngineCore.js.map +1 -0
  84. package/dist/runtime/core/cohort.d.ts +40 -0
  85. package/dist/runtime/core/cohort.d.ts.map +1 -0
  86. package/dist/runtime/core/cohort.js +49 -0
  87. package/dist/runtime/core/cohort.js.map +1 -0
  88. package/dist/runtime/core/engine-input.d.ts +114 -0
  89. package/dist/runtime/core/engine-input.d.ts.map +1 -0
  90. package/dist/runtime/core/engine-input.js +19 -0
  91. package/dist/runtime/core/engine-input.js.map +1 -0
  92. package/dist/runtime/core/engine-output.d.ts +62 -0
  93. package/dist/runtime/core/engine-output.d.ts.map +1 -0
  94. package/dist/runtime/core/engine-output.js +27 -0
  95. package/dist/runtime/core/engine-output.js.map +1 -0
  96. package/dist/runtime/core/engine-readiness.d.ts +49 -0
  97. package/dist/runtime/core/engine-readiness.d.ts.map +1 -0
  98. package/dist/runtime/core/engine-readiness.js +47 -0
  99. package/dist/runtime/core/engine-readiness.js.map +1 -0
  100. package/dist/runtime/core/engine-resolver.d.ts +172 -0
  101. package/dist/runtime/core/engine-resolver.d.ts.map +1 -0
  102. package/dist/runtime/core/engine-resolver.js +170 -0
  103. package/dist/runtime/core/engine-resolver.js.map +1 -0
  104. package/dist/runtime/core/engine-stage-derivation.d.ts +19 -0
  105. package/dist/runtime/core/engine-stage-derivation.d.ts.map +1 -0
  106. package/dist/runtime/core/engine-stage-derivation.js +30 -0
  107. package/dist/runtime/core/engine-stage-derivation.js.map +1 -0
  108. package/dist/runtime/core/engine-state.d.ts +83 -0
  109. package/dist/runtime/core/engine-state.d.ts.map +1 -0
  110. package/dist/runtime/core/engine-state.js +49 -0
  111. package/dist/runtime/core/engine-state.js.map +1 -0
  112. package/dist/runtime/core/engine-transition.d.ts +49 -0
  113. package/dist/runtime/core/engine-transition.d.ts.map +1 -0
  114. package/dist/runtime/core/engine-transition.js +261 -0
  115. package/dist/runtime/core/engine-transition.js.map +1 -0
  116. package/dist/runtime/engine-context.d.ts +40 -0
  117. package/dist/runtime/engine-context.d.ts.map +1 -0
  118. package/dist/runtime/engine-context.js +32 -0
  119. package/dist/runtime/engine-context.js.map +1 -0
  120. package/dist/runtime/engine.d.ts +24 -0
  121. package/dist/runtime/engine.d.ts.map +1 -0
  122. package/dist/runtime/engine.js +24 -0
  123. package/dist/runtime/engine.js.map +1 -0
  124. package/dist/runtime/internal.d.ts +44 -0
  125. package/dist/runtime/internal.d.ts.map +1 -0
  126. package/dist/runtime/internal.js +46 -0
  127. package/dist/runtime/internal.js.map +1 -0
  128. package/dist/runtime/runtime-id.d.ts +8 -0
  129. package/dist/runtime/runtime-id.d.ts.map +1 -0
  130. package/dist/runtime/runtime-id.js +10 -0
  131. package/dist/runtime/runtime-id.js.map +1 -0
  132. package/dist/runtime/section-runtime-engine-host-context.d.ts +74 -0
  133. package/dist/runtime/section-runtime-engine-host-context.d.ts.map +1 -0
  134. package/dist/runtime/section-runtime-engine-host-context.js +96 -0
  135. package/dist/runtime/section-runtime-engine-host-context.js.map +1 -0
  136. package/dist/runtime/stage-emit-gate.d.ts +93 -0
  137. package/dist/runtime/stage-emit-gate.d.ts.map +1 -0
  138. package/dist/runtime/stage-emit-gate.js +83 -0
  139. package/dist/runtime/stage-emit-gate.js.map +1 -0
  140. package/dist/services/ToolkitCoordinator.d.ts +280 -7
  141. package/dist/services/ToolkitCoordinator.d.ts.map +1 -1
  142. package/dist/services/ToolkitCoordinator.js +412 -32
  143. package/dist/services/ToolkitCoordinator.js.map +1 -1
  144. package/dist/services/framework-error-bus.d.ts +73 -0
  145. package/dist/services/framework-error-bus.d.ts.map +1 -0
  146. package/dist/services/framework-error-bus.js +68 -0
  147. package/dist/services/framework-error-bus.js.map +1 -0
  148. package/dist/services/framework-error.d.ts +36 -1
  149. package/dist/services/framework-error.d.ts.map +1 -1
  150. package/dist/services/framework-error.js +37 -0
  151. package/dist/services/framework-error.js.map +1 -1
  152. package/dist/services/interfaces.d.ts +78 -0
  153. package/dist/services/interfaces.d.ts.map +1 -1
  154. package/dist/services/interfaces.js.map +1 -1
  155. package/dist/services/section-controller-types.d.ts +20 -0
  156. package/dist/services/section-controller-types.d.ts.map +1 -1
  157. package/dist/services/tools-config-normalizer.d.ts +23 -0
  158. package/dist/services/tools-config-normalizer.d.ts.map +1 -1
  159. package/dist/services/tools-config-normalizer.js +13 -1
  160. package/dist/services/tools-config-normalizer.js.map +1 -1
  161. package/dist/tools/client.d.ts +0 -1
  162. package/dist/tools/client.d.ts.map +1 -1
  163. package/dist/tools/client.js +0 -2
  164. package/dist/tools/client.js.map +1 -1
  165. package/dist/tools/types.d.ts +0 -26
  166. package/dist/tools/types.d.ts.map +1 -1
  167. package/package.json +23 -7
  168. package/dist/runtime/runtime-event-guards.d.ts +0 -2
  169. package/dist/runtime/runtime-event-guards.d.ts.map +0 -1
  170. package/dist/runtime/runtime-event-guards.js +0 -4
  171. package/dist/runtime/runtime-event-guards.js.map +0 -1
  172. package/dist/tools/tool-coordinator.d.ts +0 -72
  173. package/dist/tools/tool-coordinator.d.ts.map +0 -1
  174. package/dist/tools/tool-coordinator.js +0 -194
  175. package/dist/tools/tool-coordinator.js.map +0 -1
  176. package/dist/types/events.d.ts +0 -157
  177. package/dist/types/events.d.ts.map +0 -1
  178. package/dist/types/events.js +0 -11
  179. package/dist/types/events.js.map +0 -1
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Section runtime engine outputs (M7 — Variant C, layered core).
3
+ *
4
+ * Outputs are the closed discriminated union of effects the transition
5
+ * function returns. The adapter (PR 2) takes the output array, walks
6
+ * it in order, and dispatches each one to the right bridge (DOM
7
+ * events, framework-error bus, subscriber fan-out).
8
+ *
9
+ * Outputs carry only plain data so the transition table can be tested
10
+ * exhaustively without any DOM or coordinator wiring.
11
+ *
12
+ * Adjustment A2 from the M7 implementation plan: `loading-complete`
13
+ * is an output, **not** an FSM phase. The transition emits it from
14
+ * the `interactive` phase when the readiness signals indicate every
15
+ * item has finished loading. This mirrors today's
16
+ * `pie-loading-complete` DOM event semantics.
17
+ *
18
+ * The deprecated readiness output kinds (`readiness-change`,
19
+ * `interaction-ready`, `ready`) were removed in the broad
20
+ * architecture review compat sweep along with their DOM-event bridge
21
+ * (`legacy-event-bridge.ts`). Stage and readiness changes now flow
22
+ * through `stage-change` (with `EngineReadinessDetail` available via
23
+ * `SectionEngineCore.getState()` / kernel `selectReadiness()`); the
24
+ * "all items loaded" signal flows through `loading-complete` only.
25
+ */
26
+ import type { Stage, StageStatus } from "@pie-players/pie-players-shared/pie";
27
+ import type { CohortKey } from "./cohort.js";
28
+ import type { FrameworkErrorModel } from "../../services/framework-error.js";
29
+ /**
30
+ * Stage transition. The adapter dispatches a `pie-stage-change` DOM
31
+ * event with the canonical detail and forwards to subscribers /
32
+ * coordinator. The status indicates whether the stage was entered,
33
+ * skipped, or recorded as failed.
34
+ */
35
+ export type EngineOutputStageChange = {
36
+ kind: "stage-change";
37
+ stage: Stage;
38
+ status: StageStatus;
39
+ cohort: CohortKey | null;
40
+ };
41
+ /**
42
+ * Canonical `pie-loading-complete` emit (M6 D1). One-shot per cohort.
43
+ * Fires from the `interactive` phase when loaded == items count and
44
+ * the readiness signals satisfy `allLoadingComplete`.
45
+ */
46
+ export type EngineOutputLoadingComplete = {
47
+ kind: "loading-complete";
48
+ cohort: CohortKey;
49
+ itemCount: number;
50
+ loadedCount: number;
51
+ };
52
+ /**
53
+ * Framework error fan-out. Mirrors the M3 `framework-error` DOM event
54
+ * and the `subscribeFrameworkErrors` listener channel. Emitted on
55
+ * every `framework-error` input.
56
+ */
57
+ export type EngineOutputFrameworkError = {
58
+ kind: "framework-error";
59
+ error: FrameworkErrorModel;
60
+ };
61
+ export type SectionEngineOutput = EngineOutputStageChange | EngineOutputLoadingComplete | EngineOutputFrameworkError;
62
+ //# sourceMappingURL=engine-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-output.d.ts","sourceRoot":"","sources":["../../../src/runtime/core/engine-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACxC,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,mBAAmB,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC5B,uBAAuB,GACvB,2BAA2B,GAC3B,0BAA0B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Section runtime engine outputs (M7 — Variant C, layered core).
3
+ *
4
+ * Outputs are the closed discriminated union of effects the transition
5
+ * function returns. The adapter (PR 2) takes the output array, walks
6
+ * it in order, and dispatches each one to the right bridge (DOM
7
+ * events, framework-error bus, subscriber fan-out).
8
+ *
9
+ * Outputs carry only plain data so the transition table can be tested
10
+ * exhaustively without any DOM or coordinator wiring.
11
+ *
12
+ * Adjustment A2 from the M7 implementation plan: `loading-complete`
13
+ * is an output, **not** an FSM phase. The transition emits it from
14
+ * the `interactive` phase when the readiness signals indicate every
15
+ * item has finished loading. This mirrors today's
16
+ * `pie-loading-complete` DOM event semantics.
17
+ *
18
+ * The deprecated readiness output kinds (`readiness-change`,
19
+ * `interaction-ready`, `ready`) were removed in the broad
20
+ * architecture review compat sweep along with their DOM-event bridge
21
+ * (`legacy-event-bridge.ts`). Stage and readiness changes now flow
22
+ * through `stage-change` (with `EngineReadinessDetail` available via
23
+ * `SectionEngineCore.getState()` / kernel `selectReadiness()`); the
24
+ * "all items loaded" signal flows through `loading-complete` only.
25
+ */
26
+ export {};
27
+ //# sourceMappingURL=engine-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-output.js","sourceRoot":"","sources":["../../../src/runtime/core/engine-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Readiness derivation for the section runtime engine (M7).
3
+ *
4
+ * Canonical home of `createReadinessDetail` and `resolveReadinessPhase`.
5
+ * As of M7 PR 7 the previous duplicates in
6
+ * `packages/section-player/src/components/shared/section-player-readiness.ts`
7
+ * have been deleted; section-player now consumes these helpers via
8
+ * `@pie-players/pie-assessment-toolkit/runtime/internal`.
9
+ *
10
+ * Type duplication note: the public DOM-event detail aliases
11
+ * (`SectionPlayerReadinessChangeDetail` /
12
+ * `SectionPlayerReadinessPhase`) still live in section-player's
13
+ * `contracts/public-events.ts` because that file is part of section-
14
+ * player's published custom-element contract. The toolkit core defines
15
+ * `EngineReadinessPhase` independently so it has zero section-player
16
+ * imports. The two definitions must stay structurally identical;
17
+ * that invariant is covered by the readiness assertions in this
18
+ * package's tests, which mirror the section-player suite.
19
+ */
20
+ /**
21
+ * Coarse readiness phase label, derived from the four readiness
22
+ * signals. Surfaced via the kernel's `selectReadiness()` /
23
+ * `getSnapshot().readiness` selectors; M6 stages own the stage-level
24
+ * transitions on `pie-stage-change` and use this phase as a
25
+ * convenience label only. The deprecated `readiness-change` DOM
26
+ * event that used to surface this directly was removed in the broad
27
+ * architecture review compat sweep alongside its
28
+ * `legacy-event-bridge`.
29
+ */
30
+ export type EngineReadinessPhase = "bootstrapping" | "interaction-ready" | "loading" | "ready" | "error";
31
+ export type EngineReadinessSignals = {
32
+ sectionReady: boolean;
33
+ interactionReady: boolean;
34
+ allLoadingComplete: boolean;
35
+ runtimeError: boolean;
36
+ };
37
+ export type EngineReadinessDetail = {
38
+ phase: EngineReadinessPhase;
39
+ interactionReady: boolean;
40
+ allLoadingComplete: boolean;
41
+ reason?: string;
42
+ };
43
+ export declare function resolveReadinessPhase(signals: EngineReadinessSignals): EngineReadinessPhase;
44
+ export declare function createReadinessDetail(args: {
45
+ mode: "progressive" | "strict";
46
+ signals: EngineReadinessSignals;
47
+ reason?: string;
48
+ }): EngineReadinessDetail;
49
+ //# sourceMappingURL=engine-readiness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-readiness.d.ts","sourceRoot":"","sources":["../../../src/runtime/core/engine-readiness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,GAC7B,eAAe,GACf,mBAAmB,GACnB,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACpC,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACnC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,oBAAoB,CAMtB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC3C,IAAI,EAAE,aAAa,GAAG,QAAQ,CAAC;IAC/B,OAAO,EAAE,sBAAsB,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,qBAAqB,CAiBxB"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Readiness derivation for the section runtime engine (M7).
3
+ *
4
+ * Canonical home of `createReadinessDetail` and `resolveReadinessPhase`.
5
+ * As of M7 PR 7 the previous duplicates in
6
+ * `packages/section-player/src/components/shared/section-player-readiness.ts`
7
+ * have been deleted; section-player now consumes these helpers via
8
+ * `@pie-players/pie-assessment-toolkit/runtime/internal`.
9
+ *
10
+ * Type duplication note: the public DOM-event detail aliases
11
+ * (`SectionPlayerReadinessChangeDetail` /
12
+ * `SectionPlayerReadinessPhase`) still live in section-player's
13
+ * `contracts/public-events.ts` because that file is part of section-
14
+ * player's published custom-element contract. The toolkit core defines
15
+ * `EngineReadinessPhase` independently so it has zero section-player
16
+ * imports. The two definitions must stay structurally identical;
17
+ * that invariant is covered by the readiness assertions in this
18
+ * package's tests, which mirror the section-player suite.
19
+ */
20
+ export function resolveReadinessPhase(signals) {
21
+ if (signals.runtimeError)
22
+ return "error";
23
+ if (signals.allLoadingComplete)
24
+ return "ready";
25
+ if (signals.interactionReady)
26
+ return "interaction-ready";
27
+ if (signals.sectionReady)
28
+ return "loading";
29
+ return "bootstrapping";
30
+ }
31
+ export function createReadinessDetail(args) {
32
+ // Final ready must always be gated by section lifecycle and complete loading.
33
+ const finalReady = args.signals.sectionReady && args.signals.allLoadingComplete;
34
+ const interactionReady = args.mode === "strict" ? finalReady : args.signals.interactionReady;
35
+ const phase = resolveReadinessPhase({
36
+ ...args.signals,
37
+ allLoadingComplete: finalReady,
38
+ interactionReady,
39
+ });
40
+ return {
41
+ phase,
42
+ interactionReady,
43
+ allLoadingComplete: finalReady,
44
+ reason: args.reason,
45
+ };
46
+ }
47
+ //# sourceMappingURL=engine-readiness.js.map
@@ -0,0 +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"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Section runtime engine resolver (M7).
3
+ *
4
+ * Canonical home of `resolveRuntime`, `resolveToolsConfig`, and their
5
+ * supporting helpers/types. As of M7 PR 7 the previous duplicates in
6
+ * `packages/section-player/src/components/shared/section-player-runtime.ts`
7
+ * have been deleted; section-player now consumes these helpers via
8
+ * `@pie-players/pie-assessment-toolkit/runtime/internal`.
9
+ *
10
+ * What is NOT absorbed in this module:
11
+ * - `resolvePlayerRuntime` stays in section-player because it depends on
12
+ * `DEFAULT_PLAYER_DEFINITIONS` (which side-effect-imports the
13
+ * item-player package). The toolkit core stays free of that
14
+ * dependency by exposing a parametrized orchestrator —
15
+ * `resolveSectionEngineRuntimeState` — that takes a `resolvePlayerRuntime`
16
+ * callable. The section-player wrapper
17
+ * (`resolveSectionPlayerRuntimeState` in
18
+ * `packages/section-player/src/components/shared/section-player-host-runtime.ts`)
19
+ * hands its local implementation in.
20
+ *
21
+ * The strict mirror rule (M5) and the `runtime.<key>` precedence rule
22
+ * are preserved bit-for-bit; the per-key precedence test in
23
+ * `engine-resolver.test.ts` is the guardrail.
24
+ */
25
+ import type { LoaderConfig } from "@pie-players/pie-players-shared/loader-config";
26
+ import type { LoadingCompleteDetail, StageChangeDetail } from "@pie-players/pie-players-shared/pie";
27
+ import type { FrameworkErrorModel } from "../../services/framework-error.js";
28
+ import type { ToolConfigStrictness } from "../../services/tool-config-validation.js";
29
+ export declare const DEFAULT_ASSESSMENT_ID = "section-demo-direct";
30
+ export declare const DEFAULT_PLAYER_TYPE = "iife";
31
+ export declare const DEFAULT_LAZY_INIT = true;
32
+ export declare const DEFAULT_ISOLATION = "inherit";
33
+ export declare const DEFAULT_ENV: Record<string, unknown>;
34
+ export type PlayerOverrides = {
35
+ loaderConfig?: LoaderConfig;
36
+ loaderOptions?: Record<string, unknown>;
37
+ [key: string]: unknown;
38
+ };
39
+ export type FrameworkErrorHandler = (model: FrameworkErrorModel) => void;
40
+ export type StageChangeHandler = (detail: StageChangeDetail) => void;
41
+ export type LoadingCompleteHandler = (detail: LoadingCompleteDetail) => void;
42
+ /**
43
+ * Two-tier section runtime config (M5 strict mirror, post-trim).
44
+ *
45
+ * Mirror rule: `kebab-attribute ↔ camelCaseProp ↔ runtime.<sameCamelCaseKey>`.
46
+ * `runtime.<key>` always wins over the equivalent prop/attribute.
47
+ *
48
+ * Documented exceptions (no runtime mirror, by design): identity
49
+ * (`section-id`, `attempt-id`, `section`); layout-only shell knobs
50
+ * (`show-toolbar`, `toolbar-position`, etc.); and layout-shell host
51
+ * data (`policies`, `hooks`, `toolRegistry`, `*HostButtons`). Those
52
+ * surfaces are layout-shell concerns; the runtime engine does not see
53
+ * them. See section-player's ARCHITECTURE.md for the full policy.
54
+ */
55
+ export type RuntimeConfig = {
56
+ assessmentId?: string;
57
+ playerType?: string;
58
+ player?: PlayerOverrides | null;
59
+ lazyInit?: boolean;
60
+ tools?: Record<string, unknown> | null;
61
+ accessibility?: Record<string, unknown> | null;
62
+ coordinator?: unknown;
63
+ createSectionController?: unknown;
64
+ isolation?: string;
65
+ env?: Record<string, unknown>;
66
+ toolConfigStrictness?: ToolConfigStrictness;
67
+ onFrameworkError?: FrameworkErrorHandler;
68
+ enabledTools?: string;
69
+ onStageChange?: StageChangeHandler;
70
+ onLoadingComplete?: LoadingCompleteHandler;
71
+ };
72
+ export type RuntimeInputs = {
73
+ assessmentId?: string;
74
+ playerType?: string;
75
+ player?: PlayerOverrides | null;
76
+ lazyInit?: boolean;
77
+ tools?: Record<string, unknown> | null;
78
+ accessibility?: Record<string, unknown> | null;
79
+ coordinator?: unknown;
80
+ env?: Record<string, unknown> | null;
81
+ toolConfigStrictness?: ToolConfigStrictness;
82
+ onFrameworkError?: FrameworkErrorHandler;
83
+ onStageChange?: StageChangeHandler;
84
+ onLoadingComplete?: LoadingCompleteHandler;
85
+ runtime: RuntimeConfig | null;
86
+ enabledTools: string;
87
+ };
88
+ /**
89
+ * Resolve the canonical `onFrameworkError` handler from the two-tier
90
+ * surface. Precedence (highest first): `runtime.onFrameworkError`,
91
+ * then top-level `onFrameworkError`. Layout CEs and the kernel call
92
+ * this so every entry point converges on the same handler.
93
+ */
94
+ export declare function resolveOnFrameworkError(args: {
95
+ runtime: RuntimeConfig | null;
96
+ onFrameworkError?: FrameworkErrorHandler;
97
+ }): FrameworkErrorHandler | undefined;
98
+ export declare function resolveToolsConfig(args: {
99
+ runtime: RuntimeConfig | null;
100
+ tools: Record<string, unknown> | null;
101
+ enabledTools: string;
102
+ }): {
103
+ placement: {
104
+ section?: string[] | undefined;
105
+ };
106
+ };
107
+ export declare function resolveRuntime(args: {
108
+ assessmentId: string;
109
+ playerType: string;
110
+ player: PlayerOverrides | null;
111
+ lazyInit: boolean;
112
+ accessibility: Record<string, unknown> | null;
113
+ coordinator: unknown;
114
+ env: Record<string, unknown> | null;
115
+ runtime: RuntimeConfig | null;
116
+ effectiveToolsConfig: unknown;
117
+ toolConfigStrictness?: ToolConfigStrictness;
118
+ onFrameworkError?: FrameworkErrorHandler;
119
+ onStageChange?: StageChangeHandler;
120
+ onLoadingComplete?: LoadingCompleteHandler;
121
+ }): {
122
+ assessmentId: string | undefined;
123
+ playerType: string | undefined;
124
+ player: {
125
+ loaderOptions: {
126
+ [x: string]: unknown;
127
+ };
128
+ loaderConfig: {
129
+ [x: string]: unknown;
130
+ };
131
+ } | null;
132
+ lazyInit: boolean | undefined;
133
+ accessibility: Record<string, unknown> | null | undefined;
134
+ coordinator: unknown;
135
+ createSectionController: unknown;
136
+ isolation: string;
137
+ env: Record<string, unknown>;
138
+ toolConfigStrictness: "off" | "error" | "warn";
139
+ onFrameworkError: FrameworkErrorHandler | undefined;
140
+ onStageChange: StageChangeHandler | undefined;
141
+ onLoadingComplete: LoadingCompleteHandler | undefined;
142
+ tools: unknown;
143
+ enabledTools?: string;
144
+ };
145
+ /**
146
+ * Effective runtime returned by `resolveRuntime`. The shape is exposed
147
+ * as `unknown` at the public boundary because consumers spread it into
148
+ * arbitrary host props; downstream call sites narrow with the specific
149
+ * keys they need.
150
+ */
151
+ export type EffectiveRuntime = ReturnType<typeof resolveRuntime>;
152
+ /**
153
+ * Engine-side orchestrator that mirrors the legacy
154
+ * `resolveSectionPlayerRuntimeState` from section-player but takes
155
+ * `resolvePlayerRuntime` as an injected callable so the toolkit core
156
+ * stays free of host-coupled defaults (`DEFAULT_PLAYER_DEFINITIONS`).
157
+ *
158
+ * The legacy section-player wrapper passes its local `resolvePlayerRuntime`
159
+ * here in M7 PR 5 when the kernel switches onto the engine.
160
+ */
161
+ export declare function resolveSectionEngineRuntimeState<P>(args: RuntimeInputs, deps: {
162
+ resolvePlayerRuntime: (resolverArgs: {
163
+ effectiveRuntime: Record<string, unknown>;
164
+ playerType: string;
165
+ env: Record<string, unknown> | null;
166
+ }) => P;
167
+ }): {
168
+ effectiveToolsConfig: unknown;
169
+ effectiveRuntime: EffectiveRuntime;
170
+ playerRuntime: P;
171
+ };
172
+ //# sourceMappingURL=engine-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-resolver.d.ts","sourceRoot":"","sources":["../../../src/runtime/core/engine-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,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gBAAgB,CAAC;IACnC,aAAa,EAAE,CAAC,CAAC;CACjB,CAwCA"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Section runtime engine resolver (M7).
3
+ *
4
+ * Canonical home of `resolveRuntime`, `resolveToolsConfig`, and their
5
+ * supporting helpers/types. As of M7 PR 7 the previous duplicates in
6
+ * `packages/section-player/src/components/shared/section-player-runtime.ts`
7
+ * have been deleted; section-player now consumes these helpers via
8
+ * `@pie-players/pie-assessment-toolkit/runtime/internal`.
9
+ *
10
+ * What is NOT absorbed in this module:
11
+ * - `resolvePlayerRuntime` stays in section-player because it depends on
12
+ * `DEFAULT_PLAYER_DEFINITIONS` (which side-effect-imports the
13
+ * item-player package). The toolkit core stays free of that
14
+ * dependency by exposing a parametrized orchestrator —
15
+ * `resolveSectionEngineRuntimeState` — that takes a `resolvePlayerRuntime`
16
+ * callable. The section-player wrapper
17
+ * (`resolveSectionPlayerRuntimeState` in
18
+ * `packages/section-player/src/components/shared/section-player-host-runtime.ts`)
19
+ * hands its local implementation in.
20
+ *
21
+ * The strict mirror rule (M5) and the `runtime.<key>` precedence rule
22
+ * are preserved bit-for-bit; the per-key precedence test in
23
+ * `engine-resolver.test.ts` is the guardrail.
24
+ */
25
+ import { parseToolList } from "../../services/tools-config-normalizer.js";
26
+ export const DEFAULT_ASSESSMENT_ID = "section-demo-direct";
27
+ export const DEFAULT_PLAYER_TYPE = "iife";
28
+ export const DEFAULT_LAZY_INIT = true;
29
+ export const DEFAULT_ISOLATION = "inherit";
30
+ export const DEFAULT_ENV = { mode: "gather", role: "student" };
31
+ /**
32
+ * Pick the runtime-tier value when defined, otherwise the prop/attribute
33
+ * value. The strict mirror rule means every tier-1 surface is resolved
34
+ * with this single helper; per-feature special-casing is forbidden.
35
+ */
36
+ function pick(runtimeVal, attrVal) {
37
+ return runtimeVal !== undefined ? runtimeVal : attrVal;
38
+ }
39
+ /**
40
+ * Resolve the canonical `onFrameworkError` handler from the two-tier
41
+ * surface. Precedence (highest first): `runtime.onFrameworkError`,
42
+ * then top-level `onFrameworkError`. Layout CEs and the kernel call
43
+ * this so every entry point converges on the same handler.
44
+ */
45
+ export function resolveOnFrameworkError(args) {
46
+ const r = args.runtime ?? {};
47
+ if (r.onFrameworkError !== undefined)
48
+ return r.onFrameworkError;
49
+ return args.onFrameworkError;
50
+ }
51
+ export function resolveToolsConfig(args) {
52
+ const runtimeTools = (args.runtime?.tools || args.tools || {});
53
+ // `runtime.enabledTools` is the canonical mirror; the kebab attribute is
54
+ // the easy-tier alias. Per Decision B1, it merges into
55
+ // `tools.placement.section`. The object form (`runtime.tools`) keeps
56
+ // precedence over both — that lock lives in the merge below.
57
+ //
58
+ // The deprecated `item-toolbar-tools` / `passage-toolbar-tools`
59
+ // per-region aliases were removed in the broad architecture review
60
+ // compat sweep; hosts must populate `tools.placement.item` /
61
+ // `tools.placement.passage` (object form) or
62
+ // `runtime.tools.placement.{item,passage}` directly.
63
+ const effectiveEnabledTools = pick(args.runtime?.enabledTools, args.enabledTools) ?? "";
64
+ const sectionTools = parseToolList(effectiveEnabledTools);
65
+ const placement = (runtimeTools.placement || {});
66
+ const overlayToolsConfig = {
67
+ ...runtimeTools,
68
+ placement: {
69
+ ...placement,
70
+ ...(sectionTools.length > 0 ? { section: sectionTools } : {}),
71
+ },
72
+ };
73
+ // Keep host-provided shape intact; framework-owned validation surfaces malformed config.
74
+ return overlayToolsConfig;
75
+ }
76
+ export function resolveRuntime(args) {
77
+ const r = args.runtime || {};
78
+ const topLevelPlayer = (args.player || {});
79
+ const runtimePlayer = (r.player || {});
80
+ const mergedPlayerCandidate = {
81
+ ...topLevelPlayer,
82
+ ...runtimePlayer,
83
+ loaderOptions: {
84
+ ...(topLevelPlayer.loaderOptions || {}),
85
+ ...(runtimePlayer.loaderOptions || {}),
86
+ },
87
+ loaderConfig: {
88
+ ...(topLevelPlayer.loaderConfig || {}),
89
+ ...(runtimePlayer.loaderConfig || {}),
90
+ },
91
+ };
92
+ const mergedPlayer = Object.keys(mergedPlayerCandidate).length > 0 ? mergedPlayerCandidate : null;
93
+ return {
94
+ ...r,
95
+ assessmentId: pick(r.assessmentId, args.assessmentId),
96
+ playerType: pick(r.playerType, args.playerType),
97
+ player: mergedPlayer,
98
+ lazyInit: pick(r.lazyInit, args.lazyInit),
99
+ accessibility: pick(r.accessibility, args.accessibility),
100
+ coordinator: pick(r.coordinator, args.coordinator),
101
+ createSectionController: r.createSectionController,
102
+ isolation: r.isolation ?? DEFAULT_ISOLATION,
103
+ env: pick(r.env, args.env) ?? DEFAULT_ENV,
104
+ toolConfigStrictness: pick(r.toolConfigStrictness, args.toolConfigStrictness) ?? "error",
105
+ // M3 mirror absorbed via the shared helper so every layout CE wires
106
+ // `onFrameworkError` identically.
107
+ onFrameworkError: resolveOnFrameworkError({
108
+ runtime: args.runtime,
109
+ onFrameworkError: args.onFrameworkError,
110
+ }),
111
+ // M6 mirror — `onStageChange` follows the same precedence as every
112
+ // other tier-1 surface: `runtime.onStageChange` wins over the
113
+ // top-level prop.
114
+ onStageChange: pick(r.onStageChange, args.onStageChange),
115
+ // M6 mirror — `onLoadingComplete` follows the same precedence
116
+ // rule.
117
+ onLoadingComplete: pick(r.onLoadingComplete, args.onLoadingComplete),
118
+ tools: args.effectiveToolsConfig,
119
+ };
120
+ }
121
+ /**
122
+ * Engine-side orchestrator that mirrors the legacy
123
+ * `resolveSectionPlayerRuntimeState` from section-player but takes
124
+ * `resolvePlayerRuntime` as an injected callable so the toolkit core
125
+ * stays free of host-coupled defaults (`DEFAULT_PLAYER_DEFINITIONS`).
126
+ *
127
+ * The legacy section-player wrapper passes its local `resolvePlayerRuntime`
128
+ * here in M7 PR 5 when the kernel switches onto the engine.
129
+ */
130
+ export function resolveSectionEngineRuntimeState(args, deps) {
131
+ const assessmentId = args.assessmentId ?? DEFAULT_ASSESSMENT_ID;
132
+ const playerType = args.playerType ?? DEFAULT_PLAYER_TYPE;
133
+ const player = args.player ?? null;
134
+ const lazyInit = args.lazyInit ?? DEFAULT_LAZY_INIT;
135
+ const accessibility = args.accessibility ?? null;
136
+ const coordinator = args.coordinator ?? null;
137
+ const env = args.env ?? null;
138
+ const tools = args.tools ?? null;
139
+ const effectiveToolsConfig = resolveToolsConfig({
140
+ runtime: args.runtime,
141
+ tools,
142
+ enabledTools: args.enabledTools,
143
+ });
144
+ const effectiveRuntime = resolveRuntime({
145
+ assessmentId,
146
+ playerType,
147
+ player,
148
+ lazyInit,
149
+ accessibility,
150
+ coordinator,
151
+ env,
152
+ runtime: args.runtime,
153
+ effectiveToolsConfig,
154
+ toolConfigStrictness: args.toolConfigStrictness,
155
+ onFrameworkError: args.onFrameworkError,
156
+ onStageChange: args.onStageChange,
157
+ onLoadingComplete: args.onLoadingComplete,
158
+ });
159
+ const playerRuntime = deps.resolvePlayerRuntime({
160
+ effectiveRuntime: effectiveRuntime,
161
+ playerType,
162
+ env,
163
+ });
164
+ return {
165
+ effectiveToolsConfig,
166
+ effectiveRuntime,
167
+ playerRuntime,
168
+ };
169
+ }
170
+ //# sourceMappingURL=engine-resolver.js.map
@@ -0,0 +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;AA0EF;;;;GAIG;AACH,SAAS,IAAI,CACZ,UAAyB,EACzB,OAAsB;IAEtB,OAAO,UAAU,K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AAO;QACrB,KAAK;QACL,YAAY,EAAE,IAAI,CAAC,YAAY;KAC/B,CAAC,CAAC;IACH,MAAM,gBAAgB,GAAG,cAAc,CAAC;QACvC,YAAY;QACZ,UAAU;QACV,MAAM;QACN,QAAQ;QACR,aAAa;QACb,WAAW;QACX,GAAG;QACH,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,oBAAoB;QACpB,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;QAC/C,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;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"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Stage derivation for the section runtime engine (M7).
3
+ *
4
+ * Maps the FSM phase onto the canonical M6 stage vocabulary
5
+ * (`composed`, `engine-ready`, `interactive`, `disposed`). The phase
6
+ * `idle` is the engine's "no cohort yet" state and has no stage; it
7
+ * returns `null`.
8
+ *
9
+ * This module exists as a one-line indirection because:
10
+ * - The adapter uses it to guard `pie-stage-change` emit calls.
11
+ * - The transition uses it (via the pure helper below) to decide
12
+ * when to emit `stage-change` outputs as the phase advances.
13
+ * - Future shape-specific stages (e.g. layout-only `paginated`) can
14
+ * be wired in here without rewriting callers.
15
+ */
16
+ import type { Stage } from "@pie-players/pie-players-shared/pie";
17
+ import type { SectionEnginePhase } from "./engine-state.js";
18
+ export declare function phaseToStage(phase: SectionEnginePhase): Stage | null;
19
+ //# sourceMappingURL=engine-stage-derivation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-stage-derivation.d.ts","sourceRoot":"","sources":["../../../src/runtime/core/engine-stage-derivation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,GAAG,IAAI,CAapE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Stage derivation for the section runtime engine (M7).
3
+ *
4
+ * Maps the FSM phase onto the canonical M6 stage vocabulary
5
+ * (`composed`, `engine-ready`, `interactive`, `disposed`). The phase
6
+ * `idle` is the engine's "no cohort yet" state and has no stage; it
7
+ * returns `null`.
8
+ *
9
+ * This module exists as a one-line indirection because:
10
+ * - The adapter uses it to guard `pie-stage-change` emit calls.
11
+ * - The transition uses it (via the pure helper below) to decide
12
+ * when to emit `stage-change` outputs as the phase advances.
13
+ * - Future shape-specific stages (e.g. layout-only `paginated`) can
14
+ * be wired in here without rewriting callers.
15
+ */
16
+ export function phaseToStage(phase) {
17
+ switch (phase) {
18
+ case "idle":
19
+ return null;
20
+ case "booting-section":
21
+ return "composed";
22
+ case "engine-ready":
23
+ return "engine-ready";
24
+ case "interactive":
25
+ return "interactive";
26
+ case "disposed":
27
+ return "disposed";
28
+ }
29
+ }
30
+ //# sourceMappingURL=engine-stage-derivation.js.map
@@ -0,0 +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"}