|
1 | 1 | import { debounce } from 'perfect-debounce' |
2 | 2 | import { VueAppInstance } from '../types' |
3 | 3 | import { DevToolsEvents, apiHooks, setupDevToolsPlugin } from '../api' |
4 | | -import { devtoolsContext, devtoolsState } from '../state' |
| 4 | +import { devtoolsAppRecords, devtoolsContext, devtoolsState } from '../state' |
5 | 5 | import { hook } from '../hook' |
6 | 6 | import { getAppRecord, getComponentId, getComponentInstance } from '../core/component/utils' |
7 | 7 | import { getComponentBoundingRect } from '../core/component/state/bounding-rect' |
@@ -116,8 +116,11 @@ export function registerComponentDevToolsPlugin(app: VueAppInstance) { |
116 | 116 | if (component.__VUE_DEVTOOLS_UID__ == null) |
117 | 117 | component.__VUE_DEVTOOLS_UID__ = id |
118 | 118 |
|
119 | | - if (!appRecord?.instanceMap.has(id)) |
| 119 | + if (!appRecord?.instanceMap.has(id)) { |
120 | 120 | appRecord?.instanceMap.set(id, component) |
| 121 | + // force sync appRecord instanceMap |
| 122 | + devtoolsAppRecords.active.instanceMap = appRecord!.instanceMap |
| 123 | + } |
121 | 124 | } |
122 | 125 |
|
123 | 126 | if (!appRecord) |
@@ -147,8 +150,11 @@ export function registerComponentDevToolsPlugin(app: VueAppInstance) { |
147 | 150 | if (component.__VUE_DEVTOOLS_UID__ == null) |
148 | 151 | component.__VUE_DEVTOOLS_UID__ = id |
149 | 152 |
|
150 | | - if (!appRecord?.instanceMap.has(id)) |
| 153 | + if (!appRecord?.instanceMap.has(id)) { |
| 154 | + // force sync appRecord instanceMap |
151 | 155 | appRecord?.instanceMap.set(id, component) |
| 156 | + devtoolsAppRecords.active.instanceMap = appRecord!.instanceMap |
| 157 | + } |
152 | 158 | } |
153 | 159 |
|
154 | 160 | if (!appRecord) |
@@ -177,7 +183,10 @@ export function registerComponentDevToolsPlugin(app: VueAppInstance) { |
177 | 183 | uid, |
178 | 184 | instance: component, |
179 | 185 | }) as string |
| 186 | + |
180 | 187 | appRecord?.instanceMap.delete(id) |
| 188 | + // force sync appRecord instanceMap |
| 189 | + devtoolsAppRecords.active.instanceMap = appRecord.instanceMap |
181 | 190 |
|
182 | 191 | debounceSendInspectorTree() |
183 | 192 | }) |
|
0 commit comments