UNPKG

@scalar/api-client

Version:

the open source API testing client

62 lines (61 loc) 2.52 kB
import { defineComponent as C, ref as d, computed as g, createElementBlock as r, openBlock as t, toDisplayString as o, unref as p, Fragment as c, createElementVNode as a, createCommentVNode as v, createTextVNode as i, createBlock as h, withCtx as S, normalizeStyle as f } from "vue"; import { httpStatusCodes as I } from "@scalar/oas-utils/helpers"; import y from "pretty-ms"; import b from "../../../../components/HelpfulLink.vue.js"; import { getContentLength as k } from "../helpers/get-content-length.js"; const w = { class: "text-c-1 flex gap-1.5" }, _ = { key: 0 }, B = { key: 0 }, N = { key: 1 }, M = /* @__PURE__ */ C({ __name: "ResponseMetaInformation", props: { response: {}, events: {} }, setup(m) { const l = d(), u = d(0); m.events.requestStatus.on((e) => { e === "start" ? l.value = setInterval(() => u.value += 1e3, 1e3) : (clearInterval(l.value), l.value = void 0, u.value = 0); }); const s = g(() => { const e = m.response.status; if (e) return I[e] ?? void 0; }); return (e, n) => (t(), r("div", w, [ l.value && u.value ? (t(), r("span", _, o(p(y)(u.value)), 1)) : (t(), r(c, { key: 1 }, [ a("span", null, [ n[0] || (n[0] = a("span", { class: "sr-only" }, "Response Information, Duration:", -1)), i(" " + o(p(y)(e.response.duration)), 1) ]), p(k)(e.response) ? (t(), r("span", B, [ n[1] || (n[1] = a("span", { class: "sr-only" }, ", Size:", -1)), i(" " + o(p(k)(e.response)), 1) ])) : v("", !0), s.value ? (t(), r(c, { key: 1 }, [ n[2] || (n[2] = a("span", { class: "sr-only" }, ", Status:", -1)), s.value.url ? (t(), h(b, { key: 0, class: "flex items-center gap-1.5", href: s.value.url }, { default: S(() => [ i(o(e.response.status) + " " + o(s.value.name) + " ", 1), a("span", { class: "block h-1.5 w-1.5 rounded-full", style: f({ backgroundColor: s.value.color }) }, null, 4) ]), _: 1 }, 8, ["href"])) : (t(), r("span", N, [ i(o(e.response.status) + " " + o(s.value.name) + " ", 1), a("span", { class: "block h-1.5 w-1.5 rounded-full", style: f({ backgroundColor: s.value.color }) }, null, 4) ])) ], 64)) : v("", !0) ], 64)) ])); } }); export { M as default };