@@ -72,12 +72,14 @@ Object.assign(debugConsole.style, {
7272 position : 'fixed' ,
7373 bottom : '12px' ,
7474 right : '12px' ,
75- width : '380px' ,
76- background : '#1e1e1e' ,
77- color : '#ddd' ,
78- font : '11px/1.4 monospace' ,
75+ width : '560px' ,
76+ maxWidth : 'calc(100vw - 24px)' ,
77+ background : '#ffffff' ,
78+ color : '#1f2328' ,
79+ font : '11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace' ,
80+ border : '1px solid #d0d7de' ,
7981 borderRadius : '6px' ,
80- boxShadow : '0 2px 12px rgba(0,0,0,0.4 )' ,
82+ boxShadow : '0 4px 16px rgba(31, 35, 40, 0.16 )' ,
8183 zIndex : '9999' ,
8284 overflow : 'hidden' ,
8385} ) ;
@@ -89,7 +91,8 @@ Object.assign(debugHeader.style, {
8991 alignItems : 'center' ,
9092 gap : '8px' ,
9193 padding : '6px 8px' ,
92- background : '#2d2d2d' ,
94+ background : '#f6f8fa' ,
95+ borderBottom : '1px solid #d0d7de' ,
9396 cursor : 'pointer' ,
9497 userSelect : 'none' ,
9598} ) ;
@@ -98,6 +101,7 @@ debugConsole.appendChild(debugHeader);
98101const debugTitle = document . createElement ( 'span' ) ;
99102debugTitle . textContent = 'Event console' ;
100103debugTitle . style . flex = '1' ;
104+ debugTitle . style . fontWeight = 'bold' ;
101105debugHeader . appendChild ( debugTitle ) ;
102106
103107const allEventsLabel = document . createElement ( 'label' ) ;
@@ -121,13 +125,35 @@ collapseButton.textContent = '\u2013';
121125collapseButton . style . width = '22px' ;
122126debugHeader . appendChild ( collapseButton ) ;
123127
128+ const debugBody = document . createElement ( 'div' ) ;
129+ debugConsole . appendChild ( debugBody ) ;
130+
131+ const searchBar = document . createElement ( 'div' ) ;
132+ Object . assign ( searchBar . style , {
133+ padding : '6px 8px' ,
134+ borderBottom : '1px solid #eaeef2' ,
135+ } ) ;
136+ debugBody . appendChild ( searchBar ) ;
137+
138+ const searchInput = document . createElement ( 'input' ) ;
139+ searchInput . type = 'search' ;
140+ searchInput . placeholder = 'Filter by event name or payload\u2026' ;
141+ Object . assign ( searchInput . style , {
142+ width : '100%' ,
143+ boxSizing : 'border-box' ,
144+ padding : '4px 6px' ,
145+ font : 'inherit' ,
146+ border : '1px solid #d0d7de' ,
147+ borderRadius : '4px' ,
148+ } ) ;
149+ searchBar . appendChild ( searchInput ) ;
150+
124151const debugLog = document . createElement ( 'div' ) ;
125152Object . assign ( debugLog . style , {
126153 maxHeight : '40vh' ,
127154 overflowY : 'auto' ,
128- padding : '4px 0' ,
129155} ) ;
130- debugConsole . appendChild ( debugLog ) ;
156+ debugBody . appendChild ( debugLog ) ;
131157
132158// Header clicks toggle, so the controls inside it must not bubble up.
133159[ allEventsLabel , clearButton ] . forEach ( ( el ) => {
@@ -140,28 +166,67 @@ clearButton.onclick = (event) => {
140166} ;
141167
142168const toggleCollapsed = ( ) => {
143- const collapsed = debugLog . style . display === 'none' ;
144- debugLog . style . display = collapsed ? '' : 'none' ;
169+ const collapsed = debugBody . style . display === 'none' ;
170+ debugBody . style . display = collapsed ? '' : 'none' ;
145171 collapseButton . textContent = collapsed ? '\u2013' : '+' ;
146172} ;
147173collapseButton . onclick = toggleCollapsed ;
148174debugHeader . onclick = toggleCollapsed ;
149175
176+ const applyFilter = ( entry : HTMLElement ) => {
177+ const term = searchInput . value . trim ( ) . toLowerCase ( ) ;
178+ const matches = ! term || ( entry . dataset . search ?? '' ) . includes ( term ) ;
179+ entry . style . display = matches ? '' : 'none' ;
180+ } ;
181+ searchInput . oninput = ( ) => {
182+ Array . from ( debugLog . children ) . forEach ( ( child ) => applyFilter ( child as HTMLElement ) ) ;
183+ } ;
184+
185+ const eventColor = ( name : string ) => {
186+ if ( name . startsWith ( 'HostEvent' ) ) return '#8250df' ;
187+ if ( name . startsWith ( 'EmbedEvent.ALL' ) ) return '#6e7781' ;
188+ return '#0550ae' ;
189+ } ;
190+
150191const logEvent = ( name : string , payload : unknown ) => {
151- const entry = document . createElement ( 'div' ) ;
152- Object . assign ( entry . style , {
153- padding : '4px 8px' ,
154- borderBottom : '1px solid #333' ,
155- whiteSpace : 'pre-wrap' ,
156- wordBreak : 'break-word' ,
157- } ) ;
158192 let body : string ;
159193 try {
160194 body = JSON . stringify ( payload , null , 2 ) ?? String ( payload ) ;
161195 } catch {
162- body = '<unserializable payload — see devtools>' ;
196+ body = '<unserializable payload \u2014 see devtools>' ;
163197 }
164- entry . textContent = `[${ new Date ( ) . toLocaleTimeString ( ) } ] ${ name } \n${ body } ` ;
198+
199+ const entry = document . createElement ( 'div' ) ;
200+ Object . assign ( entry . style , {
201+ padding : '5px 8px' ,
202+ borderBottom : '1px solid #eaeef2' ,
203+ } ) ;
204+ entry . dataset . search = `${ name } ${ body } ` . toLowerCase ( ) ;
205+
206+ const timestamp = document . createElement ( 'span' ) ;
207+ timestamp . textContent = `${ new Date ( ) . toLocaleTimeString ( ) } ` ;
208+ timestamp . style . color = '#6e7781' ;
209+
210+ const label = document . createElement ( 'span' ) ;
211+ label . textContent = name ;
212+ label . style . color = eventColor ( name ) ;
213+ label . style . fontWeight = 'bold' ;
214+
215+ const payloadBlock = document . createElement ( 'pre' ) ;
216+ Object . assign ( payloadBlock . style , {
217+ margin : '2px 0 0' ,
218+ whiteSpace : 'pre-wrap' ,
219+ wordBreak : 'break-word' ,
220+ color : '#57606a' ,
221+ font : 'inherit' ,
222+ } ) ;
223+ payloadBlock . textContent = body ;
224+
225+ const titleRow = document . createElement ( 'div' ) ;
226+ titleRow . append ( timestamp , label ) ;
227+ entry . append ( titleRow , payloadBlock ) ;
228+
229+ applyFilter ( entry ) ;
165230 debugLog . appendChild ( entry ) ;
166231 debugLog . scrollTop = debugLog . scrollHeight ;
167232} ;
@@ -294,17 +359,21 @@ const addTriggerButton = (label: string, onClick: () => void) => {
294359} ;
295360
296361addTriggerButton ( 'Trigger Edit (normal)' , ( ) => {
362+ logEvent ( 'HostEvent.Edit' , { } ) ;
297363 liveboardEmbed . trigger ( HostEvent . Edit ) ;
298364} ) ;
299365
300366addTriggerButton ( 'Trigger Edit Liveboard Action' , ( ) => {
367+ logEvent ( 'HostEvent.EditLiveboard' , { } ) ;
301368 liveboardEmbed . trigger ( HostEvent . EditLiveboard , { } ) ;
302369} ) ;
303370
304371addTriggerButton ( 'Trigger Edit Visualization' , ( ) => {
305372 if ( ! testVizId ) {
306373 console . warn ( '[debug] set testVizId to a viz GUID on this Liveboard first' ) ;
374+ logEvent ( 'HostEvent.Edit (skipped)' , { reason : 'testVizId is not set' } ) ;
307375 return ;
308376 }
377+ logEvent ( 'HostEvent.Edit' , { vizId : testVizId } ) ;
309378 liveboardEmbed . trigger ( HostEvent . Edit , { vizId : testVizId } ) ;
310379} ) ;
0 commit comments