import * as mitt from 'mitt';
import { EventType, Handler } from 'mitt';
import * as _vue_devtools_kit from '@vue/devtools-kit';
import { DevToolsType, AppRecord, CustomTab, CustomCommand, DevToolsState, ComponentTreeNode, InspectorState, RouterInfo, TimelineEvent } from '@vue/devtools-kit';
import { Plugin, Ref } from 'vue';
import { ViteDevServer, ModuleNode } from 'vite';

interface BridgeAdapterOptions {
    tracker: (fn: Function) => void;
    trigger: (data: Record<string, any>) => void;
}
type BridgeInstanceType = InstanceType<typeof Bridge>;
declare class Bridge<Events extends Record<EventType, any>, Key extends keyof Events> {
    private emitter;
    private adapter;
    constructor(adapter?: BridgeAdapterOptions);
    private _on;
    private off;
    private _emit;
    on(eventName: Key, handler: Handler<Events[Key]>): () => void;
    once(eventName: Key, handler: Handler<Events[Key]>): void;
    emit(eventName: Key, data?: any): void;
    removeAllListeners(): void;
}

declare function setupAppBridge(bridge: BridgeInstanceType): void;

declare function setupDevToolsBridge(bridge: BridgeInstanceType): void;

declare function defineDevToolsAction<T>(name: string, action: (devtools: DevToolsType, ...args: any[]) => T | Promise<T>): (...args: any[]) => Promise<T | undefined>;
declare function defineDevToolsListener<T>(name: string, fn: (devtools: DevToolsType, callback: Function) => void, options?: {
    parser?: 'json' | 'devtools';
}): (listener: (payload: T) => void) => () => void;

interface DevToolsPluginOptions {
    bridge: BridgeInstanceType;
    viewMode: 'overlay' | 'panel';
}
type DevtoolsBridgeAppRecord = Pick<AppRecord, 'name' | 'id' | 'version' | 'routerId' | 'moduleDetectives'>;
declare function createDevToolsVuePlugin(pluginOptions: DevToolsPluginOptions): Plugin;
declare function useDevToolsBridge(): Ref<Bridge<Record<mitt.EventType, any>, mitt.EventType>>;
declare function useDevToolsState(): {
    connected: Ref<boolean>;
    clientConnected: Ref<boolean>;
    componentCount: Ref<number>;
    vueVersion: Ref<string>;
    tabs: Ref<CustomTab[]>;
    commands: Ref<CustomCommand[]>;
    vitePluginDetected: Ref<boolean>;
    appRecords: Ref<DevtoolsBridgeAppRecord[]>;
    activeAppRecordId: Ref<string>;
};

declare function prepareInjection(bridge: BridgeInstanceType): void;

declare enum HandShakeEvents {
    SYN = "syn",
    SYN_ACK = "syn-ack",
    ACK = "ack"
}
declare class HandShake {
    socket: BridgeInstanceType;
    constructor(bridge: BridgeInstanceType);
}
declare class HandShakeClient extends HandShake {
    constructor(bridge: BridgeInstanceType);
    onnConnect(): Promise<void>;
}
declare class HandShakeServer extends HandShake {
    constructor(bridge: BridgeInstanceType);
    onnConnect(): Promise<void>;
}

declare function setDevToolsClientUrl(url: string): void;
declare function getDevToolsClientUrl(): any;

declare function initViteClientHotContext(): Promise<void>;
declare function callViteServerAction<T>(name: string): (...args: any[]) => Promise<T>;
declare function defineViteClientListener(name: string): (listener: (...args: any[]) => void) => () => void;

declare function initViteServerContext(context: ViteDevServer): void;
declare function defineViteServerAction<T = Promise<unknown>>(name: string, action: (...args: any[]) => void | T): void;
declare function callViteClientListener(name: string): (...args: any[]) => Promise<void>;

type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'wasm' | 'other';
interface AssetInfo {
    path: string;
    type: AssetType;
    publicPath: string;
    filePath: string;
    size: number;
    mtime: number;
}
interface ImageMeta {
    width: number;
    height: number;
    orientation?: number;
    type?: string;
    mimeType?: string;
}
type AssetImporter = Pick<ModuleNode, 'url' | 'id'>;
interface AssetEntry {
    path: string;
    content: string;
    encoding?: BufferEncoding;
    override?: boolean;
}
interface CodeSnippet {
    code: string;
    lang: string;
    name: string;
    docs?: string;
}
interface ModuleInfo {
    id: string;
    plugins: {
        name: string;
        transform?: number;
        resolveId?: number;
    }[];
    deps: string[];
    virtual: boolean;
}

declare const checkVueInspectorDetected: (...args: any[]) => Promise<boolean | undefined>;
declare const enableVueInspector: (...args: any[]) => Promise<void | undefined>;
declare const toggleApp: (...args: any[]) => Promise<void | undefined>;
declare const editInspectorState: (...args: any[]) => Promise<void | undefined>;
declare const openInEditor: (...args: any[]) => Promise<void | undefined>;
declare const getInspectorTree: (...args: any[]) => Promise<string | undefined>;
declare const getComponentBoundingRect: (...args: any[]) => Promise<string | undefined>;
declare const inspectComponentInspector: (...args: any[]) => Promise<string | undefined>;
declare const cancelInspectComponentInspector: (...args: any[]) => Promise<void | undefined>;
declare const toggleComponentInspector: (...args: any[]) => Promise<void | undefined>;
declare const scrollToComponent: (...args: any[]) => Promise<void | undefined>;
declare const getComponentRenderCode: (...args: any[]) => Promise<any>;
declare const getInspectorState: (...args: any[]) => Promise<string | undefined>;
declare const updateInspectorTreeId: (...args: any[]) => Promise<void | undefined>;
declare const unhighlightElement: (...args: any[]) => Promise<void | undefined>;
declare const getRouterInfo: (...args: any[]) => Promise<string | undefined>;
declare const navigateAction: (...args: any[]) => Promise<void | undefined>;
declare const getMatchedRoutes: (...args: any[]) => Promise<string | undefined>;
declare const getTimelineLayer: (...args: any[]) => Promise<_vue_devtools_kit.TimelineLayerItem[] | undefined>;
declare const getDevToolsState: (...args: any[]) => Promise<{
    connected: boolean;
    clientConnected: boolean;
    vueVersion: string;
    tabs: _vue_devtools_kit.CustomTab[];
    commands: _vue_devtools_kit.CustomCommand[];
    vitePluginDetected: boolean;
    appRecords: {
        id: string | number;
        name: string;
        version: string | undefined;
        routerId: string | undefined;
        moduleDetectives: {
            vueRouter: boolean;
            pinia: boolean;
            vueI18n: boolean;
        } | undefined;
    }[];
    activeAppRecordId: string | null;
} | undefined>;
declare const toggleHighPerfMode: (...args: any[]) => Promise<void | undefined>;

declare const onDevToolsStateUpdated: (listener: (payload: DevToolsState & {
    vueVersion: string;
}) => void) => () => void;
declare const onCustomTabsUpdated: (listener: (payload: CustomTab[]) => void) => () => void;
declare const onCustomCommandsUpdated: (listener: (payload: CustomCommand[]) => void) => () => void;
declare const onInspectorTreeUpdated: (listener: (payload: {
    inspectorId: string;
    data: ComponentTreeNode[];
}) => void) => () => void;
declare const onInspectorStateUpdated: (listener: (payload: {
    inspectorId: string;
    state?: InspectorState[] | undefined;
    getters?: InspectorState[] | undefined;
}) => void) => () => void;
declare const onRouterInfoUpdated: (listener: (payload: RouterInfo) => void) => () => void;
declare const onAddTimelineEvent: (listener: (payload: TimelineEvent) => void) => () => void;

declare function initAppSeparateWindow(): void;
declare function initDevToolsSeparateWindowBridge(channel: BroadcastChannel): Bridge<Record<mitt.EventType, any>, mitt.EventType>;
declare function initDevToolsSeparateWindow(options?: {
    onConnected?: (channel: BroadcastChannel) => void;
}): void;

export { type AssetEntry, type AssetImporter, type AssetInfo, type AssetType, Bridge, type BridgeAdapterOptions, type BridgeInstanceType, type CodeSnippet, type DevToolsPluginOptions, type DevtoolsBridgeAppRecord, HandShakeClient, HandShakeEvents, HandShakeServer, type ImageMeta, type ModuleInfo, callViteClientListener, callViteServerAction, cancelInspectComponentInspector, checkVueInspectorDetected, createDevToolsVuePlugin, defineDevToolsAction, defineDevToolsListener, defineViteClientListener, defineViteServerAction, editInspectorState, enableVueInspector, getComponentBoundingRect, getComponentRenderCode, getDevToolsClientUrl, getDevToolsState, getInspectorState, getInspectorTree, getMatchedRoutes, getRouterInfo, getTimelineLayer, initAppSeparateWindow, initDevToolsSeparateWindow, initDevToolsSeparateWindowBridge, initViteClientHotContext, initViteServerContext, inspectComponentInspector, navigateAction, onAddTimelineEvent, onCustomCommandsUpdated, onCustomTabsUpdated, onDevToolsStateUpdated, onInspectorStateUpdated, onInspectorTreeUpdated, onRouterInfoUpdated, openInEditor, prepareInjection, scrollToComponent, setDevToolsClientUrl, setupAppBridge, setupDevToolsBridge, toggleApp, toggleComponentInspector, toggleHighPerfMode, unhighlightElement, updateInspectorTreeId, useDevToolsBridge, useDevToolsState };
