@@ -17,6 +17,8 @@ import {
17
17
target ,
18
18
getPluginSettings ,
19
19
SharedData ,
20
+ isBrowser ,
21
+ raf ,
20
22
} from '@vue-devtools/shared-utils'
21
23
import debounce from 'lodash/debounce'
22
24
import throttle from 'lodash/throttle'
@@ -54,6 +56,8 @@ export async function initBackend (bridge: Bridge) {
54
56
persist : false ,
55
57
} )
56
58
59
+ SharedData . isBrowser = isBrowser
60
+
57
61
initOnPageConfig ( )
58
62
59
63
if ( ! connected ) {
@@ -180,7 +184,7 @@ async function connect () {
180
184
for ( let i = 0 ; i < parentInstances . length ; i ++ ) {
181
185
const parentId = await getComponentId ( app , parentUid , parentInstances [ i ] , ctx )
182
186
if ( i < 2 && isSubscribed ( BridgeSubscriptions . COMPONENT_TREE , sub => sub . payload . instanceId === parentId ) ) {
183
- requestAnimationFrame ( ( ) => {
187
+ raf ( ( ) => {
184
188
sendComponentTreeData ( appRecord , parentId , appRecord . componentFilter , null , ctx )
185
189
} )
186
190
}
@@ -221,7 +225,7 @@ async function connect () {
221
225
if ( parentInstances . length ) {
222
226
const parentId = await getComponentId ( app , parentUid , parentInstances [ 0 ] , ctx )
223
227
if ( isSubscribed ( BridgeSubscriptions . COMPONENT_TREE , sub => sub . payload . instanceId === parentId ) ) {
224
- requestAnimationFrame ( async ( ) => {
228
+ raf ( async ( ) => {
225
229
try {
226
230
sendComponentTreeData ( await getAppRecord ( app , ctx ) , parentId , appRecord . componentFilter , null , ctx )
227
231
} catch ( e ) {
@@ -449,13 +453,14 @@ function connectBridge () {
449
453
const [ el ] = await ctx . currentAppRecord . backend . api . getComponentRootElements ( instance )
450
454
if ( el ) {
451
455
// @ts -ignore
452
- window . __VUE_DEVTOOLS_INSPECT_TARGET__ = el
456
+ target . __VUE_DEVTOOLS_INSPECT_TARGET__ = el
453
457
ctx . bridge . send ( BridgeEvents . TO_FRONT_COMPONENT_INSPECT_DOM , null )
454
458
}
455
459
}
456
460
} )
457
461
458
462
ctx . bridge . on ( BridgeEvents . TO_BACK_COMPONENT_SCROLL_TO , async ( { instanceId } ) => {
463
+ if ( ! isBrowser ) return
459
464
const instance = getComponentInstance ( ctx . currentAppRecord , instanceId , ctx )
460
465
if ( instance ) {
461
466
const [ el ] = await ctx . currentAppRecord . backend . api . getComponentRootElements ( instance )
@@ -494,6 +499,7 @@ function connectBridge () {
494
499
} )
495
500
496
501
ctx . bridge . on ( BridgeEvents . TO_BACK_COMPONENT_RENDER_CODE , async ( { instanceId } ) => {
502
+ if ( ! isBrowser ) return
497
503
const instance = getComponentInstance ( ctx . currentAppRecord , instanceId , ctx )
498
504
if ( instance ) {
499
505
const { code } = await ctx . currentAppRecord . backend . api . getComponentRenderCode ( instance )
0 commit comments