Skip to content

Commit

Permalink
perf(kit): skip sending inspector tree/state updates when high-perf m…
Browse files Browse the repository at this point in the history
…ode is enabled
  • Loading branch information
webfansplz committed Oct 29, 2024
1 parent 588d91e commit f98da4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/devtools-kit/src/core/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { RouteLocationNormalizedLoaded, Router, RouteRecordRaw } from 'vue-
import type { AppRecord } from '../../types'
import { deepClone, target as global } from '@vue/devtools-shared'
import { debounce } from 'perfect-debounce'
import { devtoolsContext, DevToolsMessagingHookKeys } from '../../ctx'
import { devtoolsContext, DevToolsMessagingHookKeys, devtoolsState } from '../../ctx'
import { ROUTER_INFO_KEY, ROUTER_KEY } from '../../ctx/router'
import { hook } from '../../hook'
// import { DevToolsEvents, apiHooks } from '../../api/hook'
Expand Down Expand Up @@ -66,6 +66,8 @@ export function normalizeRouterInfo(appRecord: AppRecord, activeAppRecord: { val
return

init()
if (devtoolsState.highPerfModeEnabled)
return
devtoolsContext.hooks.callHook(DevToolsMessagingHookKeys.ROUTER_INFO_UPDATED, { state: global[ROUTER_INFO_KEY] })
}, 200))
}
Expand Down
6 changes: 3 additions & 3 deletions packages/devtools-kit/src/ctx/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { getComponentBoundingRect } from '../core/component/state/bounding-rect'
import { getInstanceName } from '../core/component/utils'
import { highlight, unhighlight } from '../core/component-highlighter'
import { addInspector, getInspector } from './inspector'
import { activeAppRecord, DevToolsState } from './state'
import { activeAppRecord, DevToolsState, devtoolsState } from './state'
import { addTimelineLayer } from './timeline'

// v6 plugin api hooks
Expand Down Expand Up @@ -238,7 +238,7 @@ export function createDevToolsCtxHooks() {
})

const debounceSendInspectorTree = debounce(async ({ inspectorId, plugin }) => {
if (!inspectorId || !plugin?.descriptor?.app)
if (!inspectorId || !plugin?.descriptor?.app || devtoolsState.highPerfModeEnabled)
return

// 1. get inspector
Expand Down Expand Up @@ -273,7 +273,7 @@ export function createDevToolsCtxHooks() {
hooks.hook(DevToolsContextHookKeys.SEND_INSPECTOR_TREE, debounceSendInspectorTree)

const debounceSendInspectorState = debounce(async ({ inspectorId, plugin }) => {
if (!inspectorId || !plugin?.descriptor?.app)
if (!inspectorId || !plugin?.descriptor?.app || devtoolsState.highPerfModeEnabled)
return

// 1. get inspector
Expand Down

0 comments on commit f98da4f

Please sign in to comment.