UNPKG

@scalar/api-client

Version:

the open source API testing client

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