UNPKG

@scalar/api-client

Version:

the open source API testing client

145 lines (144 loc) 6.34 kB
import { defineComponent as h, computed as b, toValue as T, createBlock as p, openBlock as u, unref as t, withCtx as m, createElementVNode as i, createVNode as n, createElementBlock as d, renderSlot as v, createCommentVNode as y, normalizeProps as W, guardReactiveProps as g } from "vue"; import { useModal as x, ScalarTeleportRoot as B } from "@scalar/components"; import { ScalarToasts as _ } from "@scalar/use-toasts"; import { extensions as C } from "@scalar/workspace-store/schemas/extensions"; import { RouterView as O } from "vue-router"; import E from "./components/CreateWorkspaceModal.vue.js"; import M from "./components/SplashScreen.vue.js"; import { useDocumentWatcher as A } from "./hooks/use-document-watcher.js"; import U from "../command-palette/TheCommandPalette.vue.js"; import { useColorMode as D } from "../../hooks/use-color-mode.js"; import { useGlobalHotKeys as V } from "../../hooks/use-global-hot-keys.js"; import I from "./components/AppSidebar.vue.js"; import N from "./components/DesktopTabs.vue.js"; import { mergeSecurity as P } from "../../blocks/scalar-auth-selector-block/helpers/merge-security.js"; import $ from "../../components/sidebar/SidebarToggle.vue.js"; const H = ["innerHTML"], L = { key: 0 }, F = { class: "relative flex h-dvh w-dvw flex-1 flex-col" }, R = { class: "flex min-h-0 flex-1 flex-row" }, z = { class: "flex flex-1 flex-col" }, G = { class: "bg-b-1 min-h-0 flex-1" }, K = { key: 1 }, j = {}, ce = /* @__PURE__ */ h({ ...j, __name: "App", props: { layout: {}, plugins: { default: () => [] }, getAppState: { type: Function }, getCommandPaletteState: { type: Function } }, setup(r, { expose: k }) { k({ openCreateWorkspace: () => l.show() }); const e = r.getAppState(), f = r.getCommandPaletteState(); typeof window < "u" && (window.dataDumpWorkspace = () => e.store.value, window.dumpAppState = () => e), V(e.eventBus, r.layout), A({ documentName: () => e.store.value?.workspace[C.workspace.activeDocument], store: e.store, initialTimeout: 5e3 }), D({ workspaceStore: e.store }); const c = (o, a) => { e.eventBus.emit("ui:navigate", { page: "workspace", path: "environment", namespace: o, workspaceSlug: a }); }, w = (o) => { if (!o) return; const a = e.workspace.workspaceList.value?.find( (s) => s.id === o ); a && c(a.namespace, a.slug); }, l = x(), S = b(() => { const o = e.store.value?.auth ? P( e.document.value?.components?.securitySchemes ?? {}, {}, e.store.value.auth, e.activeEntities.documentSlug.value ?? "" ) : {}; return { documentSlug: e.activeEntities.documentSlug.value ?? "", document: e.store.value?.workspace.activeDocument ?? null, environment: e.environment.value, eventBus: e.eventBus, exampleName: e.activeEntities.exampleName.value, layout: r.layout, method: e.activeEntities.method.value, path: e.activeEntities.path.value, workspaceStore: e.store.value, activeWorkspace: e.workspace.activeWorkspace.value, plugins: r.plugins, securitySchemes: o, isDarkMode: e.isDarkMode.value, currentTheme: e.theme.styles.value.themeStyles, customThemes: T(e.theme.customThemes) }; }); return (o, a) => (u(), p(t(B), null, { default: m(() => [ i("div", { innerHTML: t(e).theme.themeStyleTag.value }, null, 8, H), n(t(_)), t(e).store.value !== null && t(e).workspace.activeWorkspace.value !== null && !t(e).loading.value ? (u(), d("main", L, [ i("div", F, [ n(t($), { modelValue: t(e).sidebar.isOpen.value, "onUpdate:modelValue": a[0] || (a[0] = (s) => t(e).sidebar.isOpen.value = s), class: "absolute top-4 left-3 z-[60] md:hidden" }, null, 8, ["modelValue"]), i("div", R, [ n(I, { isSidebarOpen: t(e).sidebar.isOpen.value, "onUpdate:isSidebarOpen": a[1] || (a[1] = (s) => t(e).sidebar.isOpen.value = s), activeWorkspace: t(e).workspace.activeWorkspace.value, eventBus: t(e).eventBus, isWorkspaceOpen: t(e).workspace.isOpen.value, layout: r.layout, sidebarState: t(e).sidebar.state, sidebarWidth: t(e).sidebar.width.value, store: t(e).store.value, workspaces: t(e).workspace.workspaceGroups.value, "onClick:workspace": c, "onCreate:workspace": a[2] || (a[2] = (s) => t(l).show()), "onSelect:workspace": w, onSelectItem: t(e).sidebar.handleSelectItem, "onUpdate:sidebarWidth": t(e).sidebar.handleSidebarWidthUpdate }, { sidebarMenuActions: m(() => [ v(o.$slots, "sidebar-menu-actions") ]), _: 3 }, 8, ["isSidebarOpen", "activeWorkspace", "eventBus", "isWorkspaceOpen", "layout", "sidebarState", "sidebarWidth", "store", "workspaces", "onSelectItem", "onUpdate:sidebarWidth"]), i("div", z, [ r.layout === "desktop" ? (u(), p(N, { key: 0, activeTabIndex: t(e).tabs.activeTabIndex.value, eventBus: t(e).eventBus, tabs: t(e).tabs.state.value }, null, 8, ["activeTabIndex", "eventBus", "tabs"])) : y("", !0), i("div", G, [ n(t(O), W(g(S.value)), null, 16) ]) ]) ]) ]), v(o.$slots, "create-workspace", { state: t(l) }, () => [ n(E, { state: t(l), "onCreate:workspace": a[3] || (a[3] = (s) => t(e).workspace.create(s)) }, null, 8, ["state"]) ]), n(U, { eventBus: t(e).eventBus, paletteState: t(f), workspaceStore: t(e).store.value }, null, 8, ["eventBus", "paletteState", "workspaceStore"]) ])) : (u(), d("main", K, [ n(M) ])) ]), _: 3 })); } }); export { ce as default };