@@ -48,6 +48,10 @@ async function registerAppJob (options: AppRecordOptions, ctx: BackendContext) {
48
48
async function createAppRecord ( options : AppRecordOptions , backend : DevtoolsBackend , ctx : BackendContext ) {
49
49
const rootInstance = await backend . api . getAppRootInstance ( options . app )
50
50
if ( rootInstance ) {
51
+ if ( ( await backend . api . getComponentDevtoolsOptions ( rootInstance ) ) . hide ) {
52
+ return
53
+ }
54
+
51
55
recordId ++
52
56
const name = await backend . api . getAppRecordName ( options . app , recordId . toString ( ) )
53
57
const id = getAppRecordId ( options . app , slug ( name ) )
@@ -66,6 +70,7 @@ async function createAppRecord (options: AppRecordOptions, backend: DevtoolsBack
66
70
iframe : document !== el . ownerDocument ? el . ownerDocument . location . pathname : null ,
67
71
meta : options . meta ?? { } ,
68
72
}
73
+
69
74
options . app . __VUE_DEVTOOLS_APP_RECORD__ = record
70
75
const rootId = `${ record . id } :root`
71
76
record . instanceMap . set ( rootId , record . rootInstance )
@@ -82,13 +87,9 @@ async function createAppRecord (options: AppRecordOptions, backend: DevtoolsBack
82
87
83
88
await backend . api . registerApplication ( options . app )
84
89
85
- const isAppHidden = ! ! ( await record . backend . api . getComponentDevtoolsOptions ( record . rootInstance ) ) . hide
86
-
87
- if ( ! isAppHidden ) {
88
- ctx . bridge . send ( BridgeEvents . TO_FRONT_APP_ADD , {
89
- appRecord : mapAppRecord ( record ) ,
90
- } )
91
- }
90
+ ctx . bridge . send ( BridgeEvents . TO_FRONT_APP_ADD , {
91
+ appRecord : mapAppRecord ( record ) ,
92
+ } )
92
93
93
94
if ( appRecordPromises . has ( options . app ) ) {
94
95
for ( const r of appRecordPromises . get ( options . app ) ) {
@@ -97,7 +98,7 @@ async function createAppRecord (options: AppRecordOptions, backend: DevtoolsBack
97
98
}
98
99
99
100
// Auto select first app
100
- if ( ctx . currentAppRecord == null && ! isAppHidden ) {
101
+ if ( ctx . currentAppRecord == null ) {
101
102
await selectApp ( record , ctx )
102
103
}
103
104
} else {
@@ -151,22 +152,29 @@ export async function getAppRecord (app: any, ctx: BackendContext): Promise<AppR
151
152
return record
152
153
}
153
154
return new Promise ( ( resolve , reject ) => {
154
- let timedOut = false
155
- const timer = setTimeout ( ( ) => {
156
- timedOut = true
157
- reject ( new Error ( `Timed out getting app record for app ${ app } ` ) )
158
- } , 2000 )
159
155
let resolvers = appRecordPromises . get ( app )
156
+ let timedOut = false
160
157
if ( ! resolvers ) {
161
158
resolvers = [ ]
162
159
appRecordPromises . set ( app , resolvers )
163
160
}
164
- resolvers . push ( ( record ) => {
161
+ const fn = ( record ) => {
165
162
if ( ! timedOut ) {
166
163
clearTimeout ( timer )
167
164
resolve ( record )
168
165
}
169
- } )
166
+ }
167
+ resolvers . push ( fn )
168
+ const timer = setTimeout ( ( ) => {
169
+ timedOut = true
170
+ const index = resolvers . indexOf ( fn )
171
+ if ( index !== - 1 ) resolvers . splice ( index , 1 )
172
+ if ( SharedData . debugInfo ) {
173
+ // eslint-disable-next-line no-console
174
+ console . log ( 'Timed out waiting for app record' , app )
175
+ }
176
+ reject ( new Error ( `Timed out getting app record for app` ) )
177
+ } , 2000 )
170
178
} )
171
179
}
172
180
@@ -178,9 +186,7 @@ export async function sendApps (ctx: BackendContext) {
178
186
const appRecords = [ ]
179
187
180
188
for ( const appRecord of ctx . appRecords ) {
181
- if ( ! ( await appRecord . backend . api . getComponentDevtoolsOptions ( appRecord . rootInstance ) ) . hide ) {
182
- appRecords . push ( appRecord )
183
- }
189
+ appRecords . push ( appRecord )
184
190
}
185
191
186
192
ctx . bridge . send ( BridgeEvents . TO_FRONT_APP_LIST , {
0 commit comments