@@ -11,38 +11,47 @@ import { drawFrame, drawPanel } from '/src/engine/debug/index.js';
1111const theme = new Theme ( ThemeTokens ) ;
1212
1313export default class Phase19FoundationScene extends Scene {
14- constructor ( { coreServices = null } = { } ) {
14+ constructor ( { runtimeLayer = null } = { } ) {
1515 super ( ) ;
1616 this . elapsed = 0 ;
17- this . coreServices = coreServices ;
17+ this . runtimeLayer = runtimeLayer ;
1818 this . lastHeartbeatTick = 0 ;
1919 this . lastHeartbeatTime = 0 ;
20+ this . lastRuntimeTransition = 'idle' ;
2021 this . unsubscribeHeartbeat = null ;
22+ this . unsubscribeRuntimeState = null ;
2123 }
2224
2325 enter ( engine ) {
24- if ( ! this . coreServices ) return ;
25- const channel = this . coreServices . get ( 'phase19.channel' ) ;
26+ if ( ! this . runtimeLayer ) return ;
27+ this . unsubscribeRuntimeState = this . runtimeLayer . onStateChange ( ( { previous, next } ) => {
28+ this . lastRuntimeTransition = `${ previous } -> ${ next } ` ;
29+ } ) ;
30+ const channel = this . runtimeLayer . getService ( 'phase19.channel' ) ;
2631 if ( channel && typeof channel . subscribe === 'function' ) {
2732 this . unsubscribeHeartbeat = channel . subscribe ( 'phase19.heartbeat' , ( payload ) => {
2833 this . lastHeartbeatTick = Number ( payload ?. tick ) || 0 ;
2934 this . lastHeartbeatTime = Number ( payload ?. t ) || 0 ;
3035 } ) ;
3136 }
32- this . coreServices . start ( { engine, scene : this } ) ;
37+ this . runtimeLayer . start ( { engine, scene : this } ) ;
3338 }
3439
3540 update ( dtSeconds ) {
3641 this . elapsed += dtSeconds ;
37- this . coreServices ?. update ( dtSeconds , { scene : this } ) ;
42+ this . runtimeLayer ?. update ( dtSeconds , { scene : this } ) ;
3843 }
3944
4045 exit ( ) {
4146 if ( typeof this . unsubscribeHeartbeat === 'function' ) {
4247 this . unsubscribeHeartbeat ( ) ;
4348 this . unsubscribeHeartbeat = null ;
4449 }
45- this . coreServices ?. stop ( { scene : this } ) ;
50+ if ( typeof this . unsubscribeRuntimeState === 'function' ) {
51+ this . unsubscribeRuntimeState ( ) ;
52+ this . unsubscribeRuntimeState = null ;
53+ }
54+ this . runtimeLayer ?. stop ( { scene : this } ) ;
4655 }
4756
4857 render ( renderer ) {
@@ -63,20 +72,22 @@ export default class Phase19FoundationScene extends Scene {
6372 font : '16px monospace' ,
6473 } ) ;
6574
66- const lifecycle = this . coreServices ?. getLifecycleState ?. ( ) || {
67- running : false ,
68- serviceCount : 0 ,
75+ const runtimeSnapshot = this . runtimeLayer ?. getSnapshot ?. ( ) || {
76+ state : 'idle' ,
77+ tickCount : 0 ,
78+ serviceIds : [ ] ,
6979 } ;
70- const channelSnapshot = this . coreServices ?. get ?. ( 'phase19.channel' ) ?. getSnapshot ?. ( ) || {
80+ const channelSnapshot = this . runtimeLayer ?. getService ?. ( 'phase19.channel' ) ?. getSnapshot ?. ( ) || {
7181 publishedCount : 0 ,
7282 lastChannel : 'none' ,
7383 } ;
74- drawPanel ( renderer , 620 , 34 , 300 , 140 , 'Phase 19 Bootstrap' , [
75- 'Status: initialized (core services )' ,
84+ drawPanel ( renderer , 620 , 34 , 300 , 160 , 'Phase 19 Bootstrap' , [
85+ 'Status: initialized (runtime layer )' ,
7686 'Folder: samples/phase-19' ,
7787 'Entry sample: 1901' ,
78- `Running: ${ lifecycle . running ? 'yes' : 'no' } ` ,
79- `Services: ${ lifecycle . serviceCount } ` ,
88+ `Runtime: ${ runtimeSnapshot . state } | tick ${ runtimeSnapshot . tickCount } ` ,
89+ `Transition: ${ this . lastRuntimeTransition } ` ,
90+ `Services: ${ runtimeSnapshot . serviceIds . length } ` ,
8091 `Published: ${ channelSnapshot . publishedCount } (${ channelSnapshot . lastChannel } )` ,
8192 `Heartbeat tick: ${ this . lastHeartbeatTick } @ ${ this . lastHeartbeatTime . toFixed ( 2 ) } s` ,
8293 ] ) ;
0 commit comments