@@ -50,42 +50,47 @@ async function registerAppJob (options: AppRecordOptions, ctx: BackendContext) {
50
50
}
51
51
52
52
// Create app record
53
- const id = getAppRecordId ( options . app )
54
- const name = await ctx . api . getAppRecordName ( options . app , id )
55
- record = {
56
- id,
57
- name,
58
- options,
59
- backend,
60
- lastInspectedComponentId : null ,
61
- instanceMap : new Map ( ) ,
62
- rootInstance : await ctx . api . getAppRootInstance ( options . app ) ,
63
- perfGroupIds : new Map ( ) ,
64
- meta : options . meta ?? { }
65
- }
66
- options . app . __VUE_DEVTOOLS_APP_RECORD__ = record
67
- const rootId = `${ record . id } :root`
68
- record . instanceMap . set ( rootId , record . rootInstance )
69
- record . rootInstance . __VUE_DEVTOOLS_UID__ = rootId
70
- await ctx . api . registerApplication ( record )
71
- ctx . appRecords . push ( record )
72
- ctx . bridge . send ( BridgeEvents . TO_FRONT_APP_ADD , {
73
- appRecord : mapAppRecord ( record )
74
- } )
75
-
76
- if ( backend . setupApp ) {
77
- backend . setupApp ( ctx . api , record )
78
- }
53
+ const rootInstance = await ctx . api . getAppRootInstance ( options . app )
54
+ if ( rootInstance ) {
55
+ const id = getAppRecordId ( options . app )
56
+ const name = await ctx . api . getAppRecordName ( options . app , id )
57
+ record = {
58
+ id,
59
+ name,
60
+ options,
61
+ backend,
62
+ lastInspectedComponentId : null ,
63
+ instanceMap : new Map ( ) ,
64
+ rootInstance,
65
+ perfGroupIds : new Map ( ) ,
66
+ meta : options . meta ?? { }
67
+ }
68
+ options . app . __VUE_DEVTOOLS_APP_RECORD__ = record
69
+ const rootId = `${ record . id } :root`
70
+ record . instanceMap . set ( rootId , record . rootInstance )
71
+ record . rootInstance . __VUE_DEVTOOLS_UID__ = rootId
72
+ await ctx . api . registerApplication ( record )
73
+ ctx . appRecords . push ( record )
74
+ ctx . bridge . send ( BridgeEvents . TO_FRONT_APP_ADD , {
75
+ appRecord : mapAppRecord ( record )
76
+ } )
77
+
78
+ if ( backend . setupApp ) {
79
+ backend . setupApp ( ctx . api , record )
80
+ }
79
81
80
- if ( appRecordPromises . has ( options . app ) ) {
81
- for ( const r of appRecordPromises . get ( options . app ) ) {
82
- await r ( record )
82
+ if ( appRecordPromises . has ( options . app ) ) {
83
+ for ( const r of appRecordPromises . get ( options . app ) ) {
84
+ await r ( record )
85
+ }
83
86
}
84
- }
85
87
86
- // Auto select first app
87
- if ( ctx . currentAppRecord == null ) {
88
- await selectApp ( record , ctx )
88
+ // Auto select first app
89
+ if ( ctx . currentAppRecord == null ) {
90
+ await selectApp ( record , ctx )
91
+ }
92
+ } else {
93
+ console . warn ( '[Vue devtools] No root instance found for app, it might have been unmounted' , options . app )
89
94
}
90
95
91
96
break
0 commit comments