vite-plugin-vue-inspector
Version:
Jump to local IDE source code when clicking Vue elements in the browser.
28 lines (27 loc) • 800 B
JavaScript
import { n as isEnabled, t as events } from "../listeners-Tt3Dpz6u.mjs";
import { state } from "./overlay.mjs";
//#region packages/core/src/client/vite-devtools.ts
const OPEN_IN_EDITOR_RPC = "vite:core:open-in-editor";
function clientScriptSetup(ctx) {
let cleanupClick;
const deactivate = () => {
cleanupClick?.();
cleanupClick = void 0;
isEnabled.value = false;
state.isVisible = false;
};
ctx.current.events.on("entry:activated", () => {
cleanupClick?.();
cleanupClick = events.on("click", async (info) => {
await ctx.rpc.call(OPEN_IN_EDITOR_RPC, info.fullpath);
deactivate();
ctx.docks.switchEntry(null);
});
isEnabled.value = true;
});
ctx.current.events.on("entry:deactivated", () => {
deactivate();
});
}
//#endregion
export { clientScriptSetup as default };