UNPKG

@flanksource/clicky-ui

Version:

Flanksource Clicky UI — React component library built on shadcn/ui with light/dark and density theming.

76 lines (75 loc) 3.74 kB
import { jsxs, jsx } from "react/jsx-runtime"; import { Icon } from "../Icon.js"; function goroutineStateBadge(state) { if (state.includes("running")) return "bg-green-50 text-green-700 dark:bg-green-500/20 dark:text-green-300"; if (state.includes("chan") || state.includes("wait")) return "bg-blue-50 text-blue-700 dark:bg-blue-500/20 dark:text-blue-300"; if (state.includes("sleep")) return "bg-amber-50 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300"; if (state.includes("select")) return "bg-violet-50 text-violet-700 dark:bg-violet-500/20 dark:text-violet-300"; return "bg-muted text-muted-foreground"; } function goroutineStateDot(state) { if (state.includes("running")) return "bg-green-500"; if (state.includes("chan") || state.includes("wait")) return "bg-blue-500"; if (state.includes("sleep")) return "bg-amber-500"; if (state.includes("select")) return "bg-violet-500"; return "bg-muted-foreground/40"; } function GoroutineCard({ goroutine, search, hideRuntimeOnly }) { const frames = hideRuntimeOnly ? goroutine.frames.filter((frame) => !frame.runtime || frame.kind === "created_by") : goroutine.frames; const defaultOpen = goroutine.state === "running" || !!search; return /* @__PURE__ */ jsxs("details", { className: "border-0 bg-transparent", open: defaultOpen, children: [ /* @__PURE__ */ jsx("summary", { className: "cursor-pointer list-none px-0 py-1", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [ /* @__PURE__ */ jsxs("span", { className: "font-mono text-xs font-semibold text-foreground", children: [ "g", goroutine.id ] }), /* @__PURE__ */ jsxs( "span", { className: `inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] ${goroutineStateBadge( goroutine.state )}`, children: [ /* @__PURE__ */ jsx("span", { className: `h-2 w-2 rounded-full ${goroutineStateDot(goroutine.state)}` }), goroutine.rawState ] } ), /* @__PURE__ */ jsxs("span", { className: "text-[11px] text-muted-foreground", children: [ frames.length, "f" ] }), goroutine.userFrameCount > 0 && /* @__PURE__ */ jsxs("span", { className: "text-[11px] text-muted-foreground", children: [ goroutine.userFrameCount, "u" ] }), goroutine.topFunction && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-muted-foreground", children: goroutine.topFunction }) ] }) }), /* @__PURE__ */ jsx("div", { className: "pl-3 py-1 space-y-0.5", children: frames.map((frame, index) => /* @__PURE__ */ jsx(FrameRow, { frame }, `${goroutine.id}-${index}`)) }) ] }); } function FrameRow({ frame }) { return /* @__PURE__ */ jsx("div", { className: frame.runtime ? "text-muted-foreground" : "text-foreground", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-1.5", children: [ /* @__PURE__ */ jsx( Icon, { name: frame.kind === "created_by" ? "codicon:debug-restart" : frame.runtime ? "codicon:debug-step-over" : "codicon:symbol-method", className: "shrink-0 mt-0.5 text-[11px]" } ), /* @__PURE__ */ jsx("div", { className: "min-w-0", children: /* @__PURE__ */ jsxs("div", { className: "break-all font-mono text-[11px] font-semibold leading-4", children: [ frame.displayName, frame.location && /* @__PURE__ */ jsx("span", { className: "ml-2 text-[10px] font-normal opacity-80", children: frame.location }) ] }) }) ] }) }); } export { GoroutineCard, goroutineStateBadge, goroutineStateDot }; //# sourceMappingURL=GoroutineCard.js.map