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