@@ -13,6 +13,7 @@ import { scan } from './legacy/scan'
13
13
import { addBuiltinLayers , removeLayersForApp } from './timeline'
14
14
import { availableBackends , getBackend } from './backend'
15
15
import { hook } from './global-hook.js'
16
+ import { sendComponentTreeData , sendSelectedComponentData } from './component.js'
16
17
17
18
const jobs = new JobQueue ( )
18
19
@@ -64,17 +65,39 @@ async function createAppRecord(options: AppRecordOptions, backend: DevtoolsBacke
64
65
65
66
const [ el ] : HTMLElement [ ] = await backend . api . getComponentRootElements ( rootInstance )
66
67
68
+ const instanceMapRaw = new Map < string , any > ( )
69
+
67
70
const record : AppRecord = {
68
71
id,
69
72
name,
70
73
options,
71
74
backend,
72
75
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
+ } ) ,
74
96
rootInstance,
75
97
perfGroupIds : new Map ( ) ,
76
98
iframe : isBrowser && document !== el ?. ownerDocument ? el ?. ownerDocument ?. location ?. pathname : null ,
77
99
meta : options . meta ?? { } ,
100
+ missingInstanceQueue : new Set ( ) ,
78
101
}
79
102
80
103
options . app . __VUE_DEVTOOLS_APP_RECORD__ = record
0 commit comments