@@ -5,7 +5,7 @@ import { consume } from '@lit/context'
55import { type ComponentChildren , h , render , type VNode } from 'preact'
66import { customElement , query } from 'lit/decorators.js'
77
8- import { context , type TraceLog } from '../../context .js'
8+ import { mutationContext , type TraceMutation , metadataContext , type Metadata } from '../../controller/DataManager .js'
99
1010import '~icons/mdi/world.js'
1111import '../placeholder.js'
@@ -38,8 +38,11 @@ export class DevtoolsBrowser extends Element {
3838 #vdom = document . createDocumentFragment ( )
3939 #activeUrl = ''
4040
41- @consume ( { context } )
42- data : Partial < TraceLog > = { }
41+ @consume ( { context : metadataContext } )
42+ metadata : Metadata | undefined = undefined
43+
44+ @consume ( { context : mutationContext } )
45+ mutations : TraceMutation [ ] = [ ]
4346
4447 static styles = [ ...Element . styles , css `
4548 :host {
@@ -85,7 +88,7 @@ export class DevtoolsBrowser extends Element {
8588 }
8689
8790 #setIframeSize ( ) {
88- const metadata = this . data . metadata
91+ const metadata = this . metadata
8992 if ( ! this . section || ! this . iframe || ! this . header || ! metadata ) {
9093 return
9194 }
@@ -190,7 +193,7 @@ export class DevtoolsBrowser extends Element {
190193
191194 #handleChildListMutation ( mutation : TraceMutation ) {
192195 if ( mutation . addedNodes . length === 1 && ! mutation . target ) {
193- const baseUrl = this . data . metadata ?. url || 'unknown'
196+ const baseUrl = this . metadata ?. url || 'unknown'
194197 this . #renderNewDocument( mutation . addedNodes [ 0 ] as SimplifiedVNode , baseUrl )
195198 return this . #renderVdom( )
196199 }
@@ -254,7 +257,7 @@ export class DevtoolsBrowser extends Element {
254257 }
255258
256259 async #renderBrowserState ( mutationEntry ?: TraceMutation ) {
257- const mutations = this . data . mutations
260+ const mutations = this . mutations
258261 if ( ! mutations ) {
259262 return
260263 }
@@ -274,7 +277,7 @@ export class DevtoolsBrowser extends Element {
274277 . map ( ( [ , i ] ) => i )
275278 . pop ( ) || 0
276279
277- this . #activeUrl = mutations [ rootIndex ] . url || this . data . metadata ?. url || 'unknown'
280+ this . #activeUrl = mutations [ rootIndex ] . url || this . metadata ?. url || 'unknown'
278281 for ( let i = rootIndex ; i <= mutationIndex ; i ++ ) {
279282 await this . #handleMutation( mutations [ i ] ) . catch (
280283 ( err ) => console . warn ( `Failed to render mutation: ${ err . message } ` ) )
@@ -306,9 +309,9 @@ export class DevtoolsBrowser extends Element {
306309 ${ this . #activeUrl}
307310 </ div >
308311 </ header >
309- ${ this . data . mutations
312+ ${ this . mutations
310313 ? html `< iframe class ="origin-top-left "> </ iframe > `
311- : html `< wdio-devtools-placeholder style ="height: 500px "> </ wdio-devtools-placeholder > `
314+ : html `< wdio-devtools-placeholder style ="height: 100% "> </ wdio-devtools-placeholder > `
312315 }
313316 </ section >
314317 `
0 commit comments