@@ -13,6 +13,7 @@ import { scan } from './legacy/scan'
1313import { addBuiltinLayers , removeLayersForApp } from './timeline'
1414import { availableBackends , getBackend } from './backend'
1515import { hook } from './global-hook.js'
16+ import { sendComponentTreeData , sendSelectedComponentData } from './component.js'
1617
1718const jobs = new JobQueue ( )
1819
@@ -64,17 +65,39 @@ async function createAppRecord(options: AppRecordOptions, backend: DevtoolsBacke
6465
6566 const [ el ] : HTMLElement [ ] = await backend . api . getComponentRootElements ( rootInstance )
6667
68+ const instanceMapRaw = new Map < string , any > ( )
69+
6770 const record : AppRecord = {
6871 id,
6972 name,
7073 options,
7174 backend,
7275 lastInspectedComponentId : null ,
73- instanceMap : new Map ( ) ,
76+ instanceMap : new Proxy ( instanceMapRaw , {
77+ get ( target , key : string ) {
78+ if ( key === 'set' ) {
79+ return ( instanceId : string , instance : any ) => {
80+ target . set ( instanceId , instance )
81+ // The component was requested by the frontend before it was registered
82+ if ( record . missingInstanceQueue . has ( instanceId ) ) {
83+ record . missingInstanceQueue . delete ( instanceId )
84+ if ( ctx . currentAppRecord === record ) {
85+ sendComponentTreeData ( record , instanceId , record . componentFilter , null , false , ctx )
86+ if ( record . lastInspectedComponentId === instanceId ) {
87+ sendSelectedComponentData ( record , instanceId , ctx )
88+ }
89+ }
90+ }
91+ }
92+ }
93+ return target [ key ] . bind ( target )
94+ } ,
95+ } ) ,
7496 rootInstance,
7597 perfGroupIds : new Map ( ) ,
7698 iframe : isBrowser && document !== el ?. ownerDocument ? el ?. ownerDocument ?. location ?. pathname : null ,
7799 meta : options . meta ?? { } ,
100+ missingInstanceQueue : new Set ( ) ,
78101 }
79102
80103 options . app . __VUE_DEVTOOLS_APP_RECORD__ = record
0 commit comments