From f98da4f3a8cb6528845d915a34aa9dbcaee4c9ba Mon Sep 17 00:00:00 2001 From: arlo Date: Tue, 29 Oct 2024 21:38:32 +0800 Subject: [PATCH] perf(kit): skip sending inspector tree/state updates when high-perf mode is enabled --- packages/devtools-kit/src/core/router/index.ts | 4 +++- packages/devtools-kit/src/ctx/hook.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/devtools-kit/src/core/router/index.ts b/packages/devtools-kit/src/core/router/index.ts index 955ee0bc..2d5488de 100644 --- a/packages/devtools-kit/src/core/router/index.ts +++ b/packages/devtools-kit/src/core/router/index.ts @@ -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' @@ -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)) } diff --git a/packages/devtools-kit/src/ctx/hook.ts b/packages/devtools-kit/src/ctx/hook.ts index 396e5c96..bd7758af 100644 --- a/packages/devtools-kit/src/ctx/hook.ts +++ b/packages/devtools-kit/src/ctx/hook.ts @@ -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 @@ -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 @@ -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