UNPKG

@scalar/api-client

Version:

the open source API testing client

163 lines (162 loc) 6.41 kB
import { defineComponent as $, ref as F, computed as r, createElementBlock as V, createBlock as W, unref as e, openBlock as m, Fragment as z, createElementVNode as y, createVNode as l, withCtx as G, normalizeProps as K, guardReactiveProps as j } from "vue"; import { useModal as q, ScalarTeleportRoot as J } from "@scalar/components"; import { isHttpMethod as Q } from "@scalar/helpers/http/is-http-method"; import { getThemeStyles as X } from "@scalar/themes"; import { ScalarToasts as Y } from "@scalar/use-toasts"; import { createWorkspaceEventBus as Z } from "@scalar/workspace-store/events"; import { useRoute as ee, useRouter as te, RouterView as oe } from "vue-router"; import ae from "./components/CreateWorkspaceModal.vue.js"; import re from "./components/SplashScreen.vue.js"; import { useAppSidebar as se } from "./hooks/use-app-sidebar.js"; import { useDocumentWatcher as ne } from "./hooks/use-document-watcher.js"; import { useSyncPath as le } from "./hooks/use-sync-path.js"; import { useWorkspaceSelector as ce } from "./hooks/use-workspace-selector.js"; import ue from "../command-palette/components/TheCommandPalette.vue.js"; import { useCommandPaletteState as pe } from "../command-palette/hooks/use-command-palette-state.js"; import { getActiveEnvironment as ie } from "../../helpers/get-active-environment.js"; import { useColorMode as me } from "../../hooks/use-color-mode.js"; import { useGlobalHotKeys as de } from "../../hooks/use-global-hot-keys.js"; import ve from "./components/AppSidebar.vue.js"; import ke from "./components/DesktopTabs.vue.js"; import Se from "./components/WebTopNav.vue.js"; import { useTabs as fe } from "./hooks/use-tabs.js"; import { useWorkspaceClientAppEvents as we } from "./hooks/use-workspace-client-app-events.js"; const he = ["innerHTML"], We = { class: "flex min-h-0 flex-1" }, ye = { class: "bg-b-1 flex-1" }, be = {}, je = /* @__PURE__ */ $({ ...be, __name: "App", props: { layout: {}, plugins: { default: () => [] } }, setup(d) { typeof window < "u" && (window.dataDumpWorkspace = () => o.value); const s = Z({ debug: !1 }), v = F(!0), B = ee(), A = te(), c = (t) => { const a = B.params[t]; return typeof a == "string" ? a : void 0; }, k = r(() => c("workspaceSlug")), n = r(() => c("documentSlug")), S = r(() => !n.value || o.value === null ? null : o.value.workspace.documents[n.value] ?? null), f = r(() => { const t = c("pathEncoded"); return t ? decodeURIComponent(t) : void 0; }), w = r(() => { const t = c("method"); return t && Q(t) ? t : void 0; }), b = r(() => c("exampleName")), g = ce(), { store: o, workspaces: T, activeWorkspace: p, setWorkspaceId: O, createWorkspace: U } = g; me({ workspaceStore: o }); const i = se({ workspaceStore: o, documentSlug: n, path: f, method: w, exampleName: b }), E = fe({ workspaceStore: o, getEntryByLocation: i.getEntryByLocation, workspaceSlug: k, documentSlug: n, path: f, method: w }), { isLoading: x } = le({ workspaceSelectorState: g, tabsState: E, eventBus: s }), _ = pe(); we({ eventBus: s, document: S, workspaceStore: o, isSidebarOpen: v, commandPaletteState: _, sidebarState: i }), de(s, d.layout), ne({ documentName: n, store: o, initialTimeout: 5e3 }); const I = r( () => ie(o.value, S.value) ), M = r(() => { if (o.value === null) return ""; const t = o.value.workspace["x-scalar-theme"]; return t ? `<style>${X(t)}</style>` : ""; }), P = 288, D = r( () => o.value?.workspace?.["x-scalar-sidebar-width"] ?? P ), L = r( () => !!(k.value && !n.value) ), N = (t) => o.value?.update("x-scalar-sidebar-width", t), R = () => A.push({ name: "workspace.environment", params: { workspaceSlug: k.value } }), C = (t) => { t && O(t); }, H = r( () => ({ documentSlug: n.value ?? "", document: S.value, environment: I.value, eventBus: s, exampleName: b.value, layout: d.layout, method: w.value, path: f.value, workspaceStore: o.value, activeWorkspace: p.value, plugins: d.plugins }) ), h = q(); return (t, a) => e(o) !== null && e(p) !== null && !e(x) ? (m(), V(z, { key: 0 }, [ y("div", { innerHTML: M.value }, null, 8, he), l(e(J), null, { default: G(() => [ l(e(Y)), t.layout === "desktop" ? (m(), W(ke, { key: 0, eventBus: e(s), tabsState: e(E) }, null, 8, ["eventBus", "tabsState"])) : (m(), W(Se, { key: 1, activeWorkspace: e(p), workspaces: e(T), "onCreate:workspace": a[0] || (a[0] = (u) => e(h).show()), "onSelect:workspace": C }, null, 8, ["activeWorkspace", "workspaces"])), y("main", We, [ l(ve, { isSidebarOpen: v.value, "onUpdate:isSidebarOpen": a[1] || (a[1] = (u) => v.value = u), activeWorkspace: e(p), eventBus: e(s), isWorkspaceOpen: L.value, layout: t.layout, sidebarState: e(i).state, sidebarWidth: D.value, store: e(o), workspaces: e(T), "onClick:workspace": R, "onCreate:workspace": a[2] || (a[2] = (u) => e(h).show()), "onSelect:workspace": C, onSelectItem: e(i).handleSelectItem, "onUpdate:sidebarWidth": N }, null, 8, ["isSidebarOpen", "activeWorkspace", "eventBus", "isWorkspaceOpen", "layout", "sidebarState", "sidebarWidth", "store", "workspaces", "onSelectItem"]), l(ae, { state: e(h), "onCreate:workspace": a[3] || (a[3] = (u) => e(U)(u)) }, null, 8, ["state"]), l(ue, { eventBus: e(s), paletteState: e(_), workspaceStore: e(o) }, null, 8, ["eventBus", "paletteState", "workspaceStore"]), y("div", ye, [ l(e(oe), K(j(H.value)), null, 16) ]) ]) ]), _: 1 }) ], 64)) : (m(), W(re, { key: 1 })); } }); export { je as default };