diff --git a/packages/devtools-kit/src/api/plugin.ts b/packages/devtools-kit/src/api/plugin.ts index 38fa335b..21884e15 100644 --- a/packages/devtools-kit/src/api/plugin.ts +++ b/packages/devtools-kit/src/api/plugin.ts @@ -1,4 +1,5 @@ -import { PluginDescriptor, PluginSetupFunction, VueAppInstance } from '../types' +import type { App } from 'vue' +import { PluginDescriptor, PluginSetupFunction } from '../types' import { devtoolsAppRecords, devtoolsState } from '../state' import { hook } from '../hook' import { getRouterDevToolsId } from '../core/router' @@ -12,7 +13,7 @@ export function setupDevToolsPlugin(pluginDescriptor: PluginDescriptor, setupFn: return hook.setupDevToolsPlugin(pluginDescriptor, setupFn) } -export function registerPlugin(app: VueAppInstance, api: DevToolsPluginApi) { +export function registerPlugin(app: App, api: DevToolsPluginApi) { const plugins = devtoolsState.pluginBuffer.filter(([plugin]) => plugin.app === app) plugins.forEach(async ([plugin, setupFn]) => { if (plugin.packageName === 'vue-query') { diff --git a/packages/devtools-kit/src/core/app-record/index.ts b/packages/devtools-kit/src/core/app-record/index.ts index 1260aec5..6c669d6c 100644 --- a/packages/devtools-kit/src/core/app-record/index.ts +++ b/packages/devtools-kit/src/core/app-record/index.ts @@ -63,10 +63,10 @@ export function createAppRecord(app: VueAppInstance['appContext']['app']): AppRe } export async function setActiveAppRecord(appRecord: AppRecord) { - await registerComponentDevToolsPlugin(appRecord?.app as unknown as VueAppInstance) + registerComponentDevToolsPlugin(appRecord?.app as unknown as VueAppInstance) devtoolsAppRecords.active = appRecord devtoolsAppRecords.activeId = `${appRecord.id}` - registerPlugin(appRecord.app as unknown as VueAppInstance, appRecord.api!) + registerPlugin(appRecord.app!, appRecord.api!) } export async function toggleActiveAppRecord(id: string) { diff --git a/packages/devtools-kit/src/plugins/component.ts b/packages/devtools-kit/src/plugins/component.ts index f8f744e3..62edcc9e 100644 --- a/packages/devtools-kit/src/plugins/component.ts +++ b/packages/devtools-kit/src/plugins/component.ts @@ -81,7 +81,6 @@ export function registerComponentDevToolsPlugin(app: VueAppInstance) { }) api.on.editInspectorState(async (payload) => { - // @ts-expect-error expected type if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { editState(payload) await api.sendInspectorState('components') diff --git a/packages/devtools-kit/src/types/app.ts b/packages/devtools-kit/src/types/app.ts index 5f43caff..92b28ec5 100644 --- a/packages/devtools-kit/src/types/app.ts +++ b/packages/devtools-kit/src/types/app.ts @@ -25,7 +25,7 @@ export declare type PluginSettingsItem = { export interface PluginDescriptor { id: string label: string - app: VueAppInstance + app: App packageName?: string homepage?: string componentStateTypes?: string[] @@ -82,7 +82,7 @@ export type VueAppInstance = ComponentInternalInstance & { setupState: Record provides: Record ctx: Record -} +} & App export interface AppRecord { id: string | number name: string