@scalar/api-client
Version:
the open source API testing client
71 lines (70 loc) • 2.69 kB
JavaScript
import { defineComponent as T, ref as y, onBeforeMount as v, onMounted as K, onBeforeUnmount as C, watch as S, computed as b, createBlock as t, openBlock as n, unref as r, withCtx as m, createElementVNode as d, createVNode as s, createCommentVNode as k, KeepAlive as E, resolveDynamicComponent as H } from "vue";
import { addScalarClassesToHeadless as N, ScalarTeleportRoot as A } from "@scalar/components";
import { getThemeStyles as B } from "@scalar/themes";
import { useBreakpoints as D } from "@scalar/use-hooks/useBreakpoints";
import { useColorMode as L } from "@scalar/use-hooks/useColorMode";
import { ScalarToasts as M } from "@scalar/use-toasts";
import { RouterView as P } from "vue-router";
import x from "../../components/TopNav/TopNav.vue.js";
import { useSidebar as V } from "../../hooks/useSidebar.js";
import O from "./MainLayout.vue.js";
import { useActiveEntities as $ } from "../../store/active-entities.js";
import { APP_HOTKEYS as g } from "./hotkeys.js";
import { handleHotKeyDown as R, DEFAULT_HOTKEYS as U } from "../../libs/hot-keys.js";
import { useWorkspace as W } from "../../store/store.js";
const Y = {
id: "scalar-client-app",
class: "contents"
}, F = ["innerHTML"], se = /* @__PURE__ */ T({
__name: "ApiClientApp",
emits: ["newTab"],
setup(I) {
const p = { ...U, ...g }, i = y(null), u = (e) => {
i.value = e;
};
L();
const { activeWorkspace: a } = $(), { events: o } = W();
v(() => N());
const l = (e) => R(e, o.hotKeys, { hotKeys: p }), c = (e) => {
e && e.openCommandPalette && (e.openCommandPalette.preventDefault(), o.commandPalette.emit());
};
K(() => {
window.addEventListener("keydown", l), o.hotKeys.on(c);
}), C(() => {
window.removeEventListener("keydown", l), o.hotKeys.off(c);
});
const { mediaQueries: f } = D(), { setSidebarOpen: _ } = V();
S(f.xl, _, {
immediate: !0
});
const w = b(
() => a.value && `<style>${B(a.value?.themeId)}</style>`
);
return (e, Q) => (n(), t(r(A), null, {
default: m(() => [
d("div", Y, [
d("div", { innerHTML: w.value }, null, 8, F),
s(x, { openNewTab: i.value }, null, 8, ["openNewTab"]),
r(a)?.uid ? (n(), t(O, { key: 0 }, {
default: m(() => [
s(r(P), { onNewTab: u }, {
default: m(({ Component: h }) => [
(n(), t(E, null, [
(n(), t(H(h)))
], 1024))
]),
_: 1
})
]),
_: 1
})) : k("", !0),
s(r(M))
])
]),
_: 1
}));
}
});
export {
se as default
};