1-
21import { EventType , ALL_SHELL_EVENTS_ARRAY } from './ShellEvents' ;
32import { EventDirection , DebugEvent } from './models/debug/debug-event' ;
43import { MessageLogger } from './MessageLogger' ;
4+ import { TraceEntry } from './models/trace/trace-entry.model' ;
55
66interface DebuggableWindow extends Window {
77 fsmShellMessageLogger : MessageLogger | undefined ;
@@ -10,29 +10,35 @@ interface DebuggableWindow extends Window {
1010interface Routing {
1111 to ?: string [ ] ;
1212 from ?: string [ ] ;
13+ trace ?: TraceEntry [ ] ;
1314}
1415
1516const FSM_SHELL_DEBUG_KEY = 'cs.fsm-shell.debug' ;
1617
1718export class Debugger {
18-
1919 private debugMode : boolean = false ;
2020
21- constructor (
22- private winRef : Window ,
23- private debugId : string
24- ) {
21+ constructor ( private winRef : Window , private debugId : string ) {
2522 if ( this . debugId ) {
2623 const win = this . winRef as DebuggableWindow ;
2724 const localStorageValue = win . localStorage . getItem ( FSM_SHELL_DEBUG_KEY ) ;
28- if ( ! ! localStorageValue && localStorageValue . split ( ',' ) . some ( it => it === debugId ) ) {
25+ if (
26+ ! ! localStorageValue &&
27+ localStorageValue . split ( ',' ) . some ( ( it ) => it === debugId )
28+ ) {
2929 this . debugMode = true ;
3030 }
3131 }
3232 }
3333
34- public traceEvent ( direction : EventDirection , type : EventType , payload : any , routing : Routing , hasHandler : boolean ) {
35- if ( this . debugMode && ALL_SHELL_EVENTS_ARRAY . some ( it => it === type ) ) {
34+ public traceEvent (
35+ direction : EventDirection ,
36+ type : EventType ,
37+ payload : any ,
38+ routing : Routing ,
39+ hasHandler : boolean
40+ ) {
41+ if ( this . debugMode && ALL_SHELL_EVENTS_ARRAY . some ( ( it ) => it === type ) ) {
3642 const debugEvent : DebugEvent < any > = {
3743 timestamp : new Date ( ) ,
3844 component : this . debugId ,
@@ -41,8 +47,9 @@ export class Debugger {
4147 handled : direction === 'incoming' ? ( hasHandler ? 'yes' : 'no' ) : 'n/a' ,
4248 to : routing . to ,
4349 from : routing . from ,
44- payload
45- }
50+ trace : routing . trace ,
51+ payload,
52+ } ;
4653 this . logEvent ( debugEvent ) ;
4754 }
4855 }
@@ -54,5 +61,4 @@ export class Debugger {
5461 }
5562 win . fsmShellMessageLogger . push ( debugEvent , this . debugId ) ;
5663 }
57-
5864}
0 commit comments