@@ -11,20 +11,45 @@ import { drawFrame, drawPanel } from '/src/engine/debug/index.js';
1111const theme = new Theme ( ThemeTokens ) ;
1212
1313export default class Phase19FoundationScene extends Scene {
14- constructor ( ) {
14+ constructor ( { coreServices = null } = { } ) {
1515 super ( ) ;
1616 this . elapsed = 0 ;
17+ this . coreServices = coreServices ;
18+ this . lastHeartbeatTick = 0 ;
19+ this . lastHeartbeatTime = 0 ;
20+ this . unsubscribeHeartbeat = null ;
21+ }
22+
23+ enter ( engine ) {
24+ if ( ! this . coreServices ) return ;
25+ const channel = this . coreServices . get ( 'phase19.channel' ) ;
26+ if ( channel && typeof channel . subscribe === 'function' ) {
27+ this . unsubscribeHeartbeat = channel . subscribe ( 'phase19.heartbeat' , ( payload ) => {
28+ this . lastHeartbeatTick = Number ( payload ?. tick ) || 0 ;
29+ this . lastHeartbeatTime = Number ( payload ?. t ) || 0 ;
30+ } ) ;
31+ }
32+ this . coreServices . start ( { engine, scene : this } ) ;
1733 }
1834
1935 update ( dtSeconds ) {
2036 this . elapsed += dtSeconds ;
37+ this . coreServices ?. update ( dtSeconds , { scene : this } ) ;
38+ }
39+
40+ exit ( ) {
41+ if ( typeof this . unsubscribeHeartbeat === 'function' ) {
42+ this . unsubscribeHeartbeat ( ) ;
43+ this . unsubscribeHeartbeat = null ;
44+ }
45+ this . coreServices ?. stop ( { scene : this } ) ;
2146 }
2247
2348 render ( renderer ) {
2449 drawFrame ( renderer , theme , [
25- 'Sample 1901 - Phase 19 Foundation ' ,
26- 'Minimal Phase 19 scaffold with launcher wiring .' ,
27- 'No feature implementation in this foundation slice.' ,
50+ 'Sample 1901 - Phase 19 Core Services ' ,
51+ 'Minimal Phase 19 core-services skeleton wired into foundation sample .' ,
52+ 'No feature implementation in this core-services slice.' ,
2853 ] ) ;
2954
3055 renderer . drawRect ( 120 , 212 , 720 , 200 , '#0f172a' ) ;
@@ -38,12 +63,22 @@ export default class Phase19FoundationScene extends Scene {
3863 font : '16px monospace' ,
3964 } ) ;
4065
66+ const lifecycle = this . coreServices ?. getLifecycleState ?. ( ) || {
67+ running : false ,
68+ serviceCount : 0 ,
69+ } ;
70+ const channelSnapshot = this . coreServices ?. get ?. ( 'phase19.channel' ) ?. getSnapshot ?. ( ) || {
71+ publishedCount : 0 ,
72+ lastChannel : 'none' ,
73+ } ;
4174 drawPanel ( renderer , 620 , 34 , 300 , 140 , 'Phase 19 Bootstrap' , [
42- 'Status: initialized' ,
75+ 'Status: initialized (core services) ' ,
4376 'Folder: samples/phase-19' ,
4477 'Entry sample: 1901' ,
45- 'Scope: structure + wiring only' ,
46- 'Features: deferred' ,
78+ `Running: ${ lifecycle . running ? 'yes' : 'no' } ` ,
79+ `Services: ${ lifecycle . serviceCount } ` ,
80+ `Published: ${ channelSnapshot . publishedCount } (${ channelSnapshot . lastChannel } )` ,
81+ `Heartbeat tick: ${ this . lastHeartbeatTick } @ ${ this . lastHeartbeatTime . toFixed ( 2 ) } s` ,
4782 ] ) ;
4883 }
4984}
0 commit comments