little-actors-observer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/dist/ActorObserver.d.ts +13 -0
- package/dist/ConsoleApp.d.ts +5 -0
- package/dist/Overview.d.ts +7 -0
- package/dist/RequestObserver.d.ts +8 -0
- package/dist/WebSocketObserver.d.ts +4 -0
- package/dist/client.d.ts +82 -0
- package/dist/components/ui/badge.d.ts +7 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/sheet.d.ts +9 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1318 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/observer-hooks.d.ts +13 -0
- package/dist/overview-data.d.ts +14 -0
- package/dist/request-history.d.ts +9 -0
- package/dist/request-sql.d.ts +10 -0
- package/dist/standalone/app.css +2 -0
- package/dist/standalone/app.js +62 -0
- package/dist/standalone/index.html +15 -0
- package/dist/standalone.d.ts +1 -0
- package/dist/styles.css +2 -0
- package/dist/theme.css +1 -0
- package/package.json +68 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1318 @@
|
|
|
1
|
+
import { useEffect as e, useId as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
|
+
import { Box as a, CircleHelp as o, Pause as s, Play as c, RefreshCw as l, Search as u, Unplug as d, X as f } from "lucide-react";
|
|
3
|
+
import { cva as p } from "class-variance-authority";
|
|
4
|
+
import { clsx as m } from "clsx";
|
|
5
|
+
import { extendTailwindMerge as h } from "tailwind-merge";
|
|
6
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
7
|
+
import { Slot as y } from "@radix-ui/react-slot";
|
|
8
|
+
import * as b from "@radix-ui/react-dialog";
|
|
9
|
+
import { createParser as x } from "eventsource-parser";
|
|
10
|
+
//#region src/lib/utils.ts
|
|
11
|
+
var S = h({ prefix: "la" });
|
|
12
|
+
function C(...e) {
|
|
13
|
+
return S(m(e));
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/components/ui/badge.tsx
|
|
17
|
+
var w = p("la:inline-flex la:items-center la:justify-center la:gap-1.5 la:rounded-md la:border la:px-2 la:py-0.5 la:text-xs la:font-medium la:whitespace-nowrap", {
|
|
18
|
+
variants: { variant: {
|
|
19
|
+
default: "la:border-transparent la:bg-muted la:text-muted-foreground",
|
|
20
|
+
outline: "la:border-border la:text-muted-foreground"
|
|
21
|
+
} },
|
|
22
|
+
defaultVariants: { variant: "default" }
|
|
23
|
+
});
|
|
24
|
+
function T({ className: e, variant: t, ...n }) {
|
|
25
|
+
return /* @__PURE__ */ _("span", {
|
|
26
|
+
"data-slot": "badge",
|
|
27
|
+
className: C(w({ variant: t }), e),
|
|
28
|
+
...n
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/components/ui/button.tsx
|
|
33
|
+
var E = p("la:inline-flex la:shrink-0 la:items-center la:justify-center la:gap-2 la:whitespace-nowrap la:rounded-md la:text-sm la:font-medium la:outline-none la:transition-[background-color,border-color,color,box-shadow,transform] la:duration-150 la:ease-out la:active:translate-y-px la:disabled:pointer-events-none la:disabled:translate-y-0 la:disabled:opacity-45 la:focus-visible:ring-2 la:focus-visible:ring-ring la:focus-visible:ring-offset-2 la:focus-visible:ring-offset-background la:aria-invalid:border-destructive la:aria-invalid:ring-destructive/25 la:[&_svg]:pointer-events-none la:[&_svg]:shrink-0 la:[&_svg:not([class*='size-'])]:size-4", {
|
|
34
|
+
variants: {
|
|
35
|
+
variant: {
|
|
36
|
+
default: "la:bg-primary la:text-primary-foreground la:shadow-[var(--shadow-control)] la:hover:bg-primary/88",
|
|
37
|
+
destructive: "la:bg-destructive la:text-white la:hover:bg-destructive/90 la:focus-visible:ring-destructive/20 la:dark:focus-visible:ring-destructive/40 la:dark:bg-destructive/60",
|
|
38
|
+
outline: "la:border la:border-input la:bg-card la:hover:border-foreground/20 la:hover:bg-accent la:hover:text-accent-foreground la:dark:bg-card",
|
|
39
|
+
secondary: "la:bg-secondary la:text-secondary-foreground la:hover:bg-secondary/80",
|
|
40
|
+
ghost: "la:bg-transparent la:hover:bg-accent la:hover:text-accent-foreground la:dark:hover:bg-accent/50",
|
|
41
|
+
link: "la:bg-transparent la:text-primary la:underline-offset-4 la:hover:underline"
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
default: "la:h-9 la:px-4 la:py-2 la:max-md:min-h-11 la:has-[>svg]:px-3",
|
|
45
|
+
sm: "la:h-8 la:gap-1.5 la:px-3 la:max-md:min-h-11 la:has-[>svg]:px-2.5",
|
|
46
|
+
lg: "la:h-10 la:px-5 la:max-md:min-h-11 la:has-[>svg]:px-4",
|
|
47
|
+
icon: "la:size-9 la:max-md:size-11",
|
|
48
|
+
"icon-sm": "la:size-8 la:max-md:size-11",
|
|
49
|
+
"icon-lg": "la:size-10 la:max-md:size-11"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
defaultVariants: {
|
|
53
|
+
variant: "default",
|
|
54
|
+
size: "default"
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
function D({ className: e, variant: t, size: n, asChild: r = !1, ...i }) {
|
|
58
|
+
return /* @__PURE__ */ _(r ? y : "button", {
|
|
59
|
+
"data-slot": "button",
|
|
60
|
+
className: C(E({
|
|
61
|
+
variant: t,
|
|
62
|
+
size: n,
|
|
63
|
+
className: e
|
|
64
|
+
})),
|
|
65
|
+
...i
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/components/ui/input.tsx
|
|
70
|
+
function O({ className: e, type: t, ...n }) {
|
|
71
|
+
return /* @__PURE__ */ _("input", {
|
|
72
|
+
type: t,
|
|
73
|
+
"data-slot": "input",
|
|
74
|
+
className: C("la:flex la:h-9 la:w-full la:min-w-0 la:rounded-md la:border la:border-input la:bg-card la:px-3 la:py-1 la:text-sm la:text-foreground la:outline-none la:transition-colors la:placeholder:text-muted-foreground la:focus-visible:border-ring la:focus-visible:ring-2 la:focus-visible:ring-ring/20 la:disabled:cursor-not-allowed la:disabled:opacity-50 la:max-md:min-h-11", e),
|
|
75
|
+
...n
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components/ui/sheet.tsx
|
|
80
|
+
var ee = b.Root, te = b.Title, k = b.Description;
|
|
81
|
+
function ne({ className: e, children: t, container: n, ...r }) {
|
|
82
|
+
return /* @__PURE__ */ v(b.Portal, {
|
|
83
|
+
container: n,
|
|
84
|
+
children: [/* @__PURE__ */ _(b.Overlay, { className: "la-sheet-overlay" }), /* @__PURE__ */ v(b.Content, {
|
|
85
|
+
"data-slot": "sheet-content",
|
|
86
|
+
className: C("la-observer la-sheet", e),
|
|
87
|
+
...r,
|
|
88
|
+
children: [t, /* @__PURE__ */ _(b.Close, {
|
|
89
|
+
asChild: !0,
|
|
90
|
+
children: /* @__PURE__ */ _(D, {
|
|
91
|
+
className: "la-sheet-close",
|
|
92
|
+
variant: "ghost",
|
|
93
|
+
size: "icon",
|
|
94
|
+
"aria-label": "Close",
|
|
95
|
+
children: /* @__PURE__ */ _(f, { "aria-hidden": "true" })
|
|
96
|
+
})
|
|
97
|
+
})]
|
|
98
|
+
})]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/components/ui/table.tsx
|
|
103
|
+
function A({ className: e, ...t }) {
|
|
104
|
+
return /* @__PURE__ */ _("div", {
|
|
105
|
+
"data-slot": "table-container",
|
|
106
|
+
className: "la:relative la:w-full la:overflow-x-auto",
|
|
107
|
+
children: /* @__PURE__ */ _("table", {
|
|
108
|
+
"data-slot": "table",
|
|
109
|
+
className: C("la:w-full la:caption-bottom la:text-sm la:tabular-nums", e),
|
|
110
|
+
...t
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function j({ className: e, ...t }) {
|
|
115
|
+
return /* @__PURE__ */ _("thead", {
|
|
116
|
+
"data-slot": "table-header",
|
|
117
|
+
className: C("la:[&_tr]:border-b", e),
|
|
118
|
+
...t
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function M({ className: e, ...t }) {
|
|
122
|
+
return /* @__PURE__ */ _("tbody", {
|
|
123
|
+
"data-slot": "table-body",
|
|
124
|
+
className: C("la:[&_tr:last-child]:border-0", e),
|
|
125
|
+
...t
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function N({ className: e, ...t }) {
|
|
129
|
+
return /* @__PURE__ */ _("tr", {
|
|
130
|
+
"data-slot": "table-row",
|
|
131
|
+
className: C("la:border-b la:transition-colors la:duration-150 la:hover:bg-muted/60 la:data-[state=selected]:bg-muted", e),
|
|
132
|
+
...t
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function P({ className: e, ...t }) {
|
|
136
|
+
return /* @__PURE__ */ _("th", {
|
|
137
|
+
"data-slot": "table-head",
|
|
138
|
+
className: C("la:h-10 la:whitespace-nowrap la:px-3 la:text-left la:align-middle la:text-xs la:font-medium la:text-muted-foreground la:[&:has([role=checkbox])]:pr-0 la:[&>[role=checkbox]]:translate-y-[2px]", e),
|
|
139
|
+
...t
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function F({ className: e, ...t }) {
|
|
143
|
+
return /* @__PURE__ */ _("td", {
|
|
144
|
+
"data-slot": "table-cell",
|
|
145
|
+
className: C("la:whitespace-nowrap la:px-3 la:py-2.5 la:align-middle la:[&:has([role=checkbox])]:pr-0 la:[&>[role=checkbox]]:translate-y-[2px]", e),
|
|
146
|
+
...t
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/observer-hooks.ts
|
|
151
|
+
function I(t) {
|
|
152
|
+
let [n, r] = i(0), [a, o] = i(), [s, c] = i(!0), [l, u] = i(!1);
|
|
153
|
+
return e(() => {
|
|
154
|
+
let e = new AbortController(), n, r = 1e3;
|
|
155
|
+
return u(!1), c(!0), a(), () => {
|
|
156
|
+
e.abort(), clearTimeout(n);
|
|
157
|
+
};
|
|
158
|
+
function i(n) {
|
|
159
|
+
e.signal.aborted || (o({
|
|
160
|
+
client: t,
|
|
161
|
+
inventory: n,
|
|
162
|
+
updatedAt: Date.now()
|
|
163
|
+
}), u(!1), c(!1), r = 1e3);
|
|
164
|
+
}
|
|
165
|
+
async function a() {
|
|
166
|
+
try {
|
|
167
|
+
if (t.watchActors) {
|
|
168
|
+
if (await t.watchActors(i, e.signal), !e.signal.aborted) throw Error("Stream ended");
|
|
169
|
+
} else c(!0), i(await t.listActors(e.signal));
|
|
170
|
+
} catch {
|
|
171
|
+
e.signal.aborted || u(!0);
|
|
172
|
+
} finally {
|
|
173
|
+
e.signal.aborted || (c(!1), n = setTimeout(a, t.watchActors ? r : 5e3), r = Math.min(r * 2, 1e4));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, [t, n]), {
|
|
177
|
+
updatedAt: a?.client === t ? a.updatedAt : void 0,
|
|
178
|
+
inventory: a?.client === t ? a.inventory : void 0,
|
|
179
|
+
loading: s,
|
|
180
|
+
failed: l,
|
|
181
|
+
retry: () => r((e) => e + 1)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function re(t, n = !0) {
|
|
185
|
+
let [r, a] = i(), [o, s] = i(!1), [c, l] = i(0);
|
|
186
|
+
return e(() => a(void 0), [t]), e(() => {
|
|
187
|
+
if (!n) return;
|
|
188
|
+
let e, r = new AbortController(), i, o = 1e3;
|
|
189
|
+
async function c() {
|
|
190
|
+
try {
|
|
191
|
+
if (!t.watchRequests) throw Error("Request traces unavailable");
|
|
192
|
+
if (await t.watchRequests((t) => {
|
|
193
|
+
r.signal.aborted || (e = t.resumeCursor, a((e) => ie(e, t)), s(!1), o = 1e3);
|
|
194
|
+
}, r.signal, e), !r.signal.aborted) throw Error("Request stream disconnected");
|
|
195
|
+
} catch {
|
|
196
|
+
r.signal.aborted || s(!0);
|
|
197
|
+
} finally {
|
|
198
|
+
r.signal.aborted || (i = setTimeout(c, o), o = Math.min(o * 2, 1e4));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return s(!1), c(), () => {
|
|
202
|
+
r.abort(), clearTimeout(i);
|
|
203
|
+
};
|
|
204
|
+
}, [
|
|
205
|
+
t,
|
|
206
|
+
c,
|
|
207
|
+
n
|
|
208
|
+
]), {
|
|
209
|
+
page: r,
|
|
210
|
+
failed: o,
|
|
211
|
+
retry: () => l((e) => e + 1)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function ie(e, t) {
|
|
215
|
+
let n = new Map((e?.epoch === t.epoch && !t.reset ? e.records : []).map((e) => [e.eventId ?? e.sequence, e]));
|
|
216
|
+
for (let e of t.records) n.set(e.eventId ?? e.sequence, e);
|
|
217
|
+
return {
|
|
218
|
+
...t,
|
|
219
|
+
reset: t.reset || e?.epoch === t.epoch && e.reset,
|
|
220
|
+
records: [...n.values()].sort((e, t) => t.sequence - e.sequence).slice(0, t.capacity)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/client.ts
|
|
225
|
+
var L = class {
|
|
226
|
+
baseUrl;
|
|
227
|
+
request;
|
|
228
|
+
constructor(e = "/api/observe", t = globalThis.fetch.bind(globalThis)) {
|
|
229
|
+
this.baseUrl = e, this.request = t;
|
|
230
|
+
}
|
|
231
|
+
async listActors(e) {
|
|
232
|
+
let t = await this.get("actors", e);
|
|
233
|
+
if (!R(t)) throw Error("Invalid actor inventory response.");
|
|
234
|
+
return t;
|
|
235
|
+
}
|
|
236
|
+
async watchActors(e, t) {
|
|
237
|
+
return this.watch("events", "inventory", R, e, t);
|
|
238
|
+
}
|
|
239
|
+
async watchRequests(e, t, n) {
|
|
240
|
+
let r = n ? `?${new URLSearchParams({ after: n })}` : "";
|
|
241
|
+
return this.watch(`requests/events${r}`, "requests", z, e, t);
|
|
242
|
+
}
|
|
243
|
+
async query(e, t) {
|
|
244
|
+
let n = await this.request(`${this.baseUrl.replace(/\/$/u, "")}/query`, {
|
|
245
|
+
method: "POST",
|
|
246
|
+
credentials: "same-origin",
|
|
247
|
+
redirect: "error",
|
|
248
|
+
signal: t,
|
|
249
|
+
headers: {
|
|
250
|
+
"content-type": "application/json",
|
|
251
|
+
accept: "application/json"
|
|
252
|
+
},
|
|
253
|
+
body: JSON.stringify(e)
|
|
254
|
+
});
|
|
255
|
+
if (!n.ok) throw Error(`Observability query failed (HTTP ${n.status}).`);
|
|
256
|
+
let r = await n.json();
|
|
257
|
+
if (!r || typeof r != "object" || !("rows" in r) || !Array.isArray(r.rows) || r.rows.length > 500 || !("truncated" in r) || typeof r.truncated != "boolean" || !r.rows.every((e) => e && typeof e == "object" && !Array.isArray(e) && Object.values(e).every((e) => e === null || [
|
|
258
|
+
"string",
|
|
259
|
+
"boolean",
|
|
260
|
+
"number"
|
|
261
|
+
].includes(typeof e)))) throw Error("Invalid SQL query response");
|
|
262
|
+
return r;
|
|
263
|
+
}
|
|
264
|
+
async watch(e, t, n, r, i) {
|
|
265
|
+
let a = await this.request(`${this.baseUrl.replace(/\/$/u, "")}/${e}`, {
|
|
266
|
+
signal: i,
|
|
267
|
+
credentials: "same-origin",
|
|
268
|
+
redirect: "error",
|
|
269
|
+
headers: { accept: "text/event-stream" }
|
|
270
|
+
});
|
|
271
|
+
if (!a.ok || !a.headers.get("content-type")?.startsWith("text/event-stream") || !a.body) throw await a.body?.cancel(), Error("Live inventory is unavailable");
|
|
272
|
+
let o = a.body.getReader(), s = new TextDecoder(), c = x({ onEvent(e) {
|
|
273
|
+
if (i.aborted) return;
|
|
274
|
+
if (e.event === "error") throw Error("Live inventory is unavailable");
|
|
275
|
+
if (e.event !== t) return;
|
|
276
|
+
let a = JSON.parse(e.data);
|
|
277
|
+
if (!n(a)) throw Error("Invalid observer response");
|
|
278
|
+
r(a);
|
|
279
|
+
} }), l = () => {
|
|
280
|
+
o.cancel().catch(() => {});
|
|
281
|
+
};
|
|
282
|
+
i.addEventListener("abort", l, { once: !0 });
|
|
283
|
+
try {
|
|
284
|
+
for (; !i.aborted;) {
|
|
285
|
+
let { value: e, done: t } = await o.read();
|
|
286
|
+
if (t) break;
|
|
287
|
+
c.feed(s.decode(e, { stream: !0 }));
|
|
288
|
+
}
|
|
289
|
+
if (!i.aborted) throw Error("Live inventory disconnected");
|
|
290
|
+
} finally {
|
|
291
|
+
i.removeEventListener("abort", l), await o.cancel().catch(() => {}), o.releaseLock();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async checkConnection(e) {
|
|
295
|
+
let t = await this.get("connection", e);
|
|
296
|
+
if (!t || typeof t != "object" || !("connected" in t) || t.connected !== !0) throw Error("Invalid connection response.");
|
|
297
|
+
}
|
|
298
|
+
async get(e, t) {
|
|
299
|
+
let n = await this.request(`${this.baseUrl.replace(/\/$/u, "")}/${e}`, {
|
|
300
|
+
method: "GET",
|
|
301
|
+
credentials: "same-origin",
|
|
302
|
+
redirect: "error",
|
|
303
|
+
signal: t,
|
|
304
|
+
headers: { accept: "application/json" }
|
|
305
|
+
});
|
|
306
|
+
if (!n.ok) throw Error(`Connection check failed (HTTP ${n.status}).`);
|
|
307
|
+
return n.json();
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
function R(e) {
|
|
311
|
+
return !e || typeof e != "object" || !("actors" in e) || !Array.isArray(e.actors) ? !1 : e.actors.every((e) => e && typeof e.actorType == "string" && [
|
|
312
|
+
e.live,
|
|
313
|
+
e.dormant,
|
|
314
|
+
e.unknown
|
|
315
|
+
].every((e) => Number.isSafeInteger(e) && e >= 0) && Array.isArray(e.instances) && e.instances.every(ae));
|
|
316
|
+
}
|
|
317
|
+
function ae(e) {
|
|
318
|
+
return !!e && typeof e == "object" && "actorId" in e && typeof e.actorId == "string" && "status" in e && [
|
|
319
|
+
"live",
|
|
320
|
+
"dormant",
|
|
321
|
+
"unknown"
|
|
322
|
+
].includes(String(e.status)) && "connections" in e && Array.isArray(e.connections) && e.connections.every(oe) && (!("waiting" in e) || e.waiting == null || Array.isArray(e.waiting) && e.waiting.every((e) => !!e && typeof e == "object" && typeof e.id == "string" && typeof e.operation == "string"));
|
|
323
|
+
}
|
|
324
|
+
function oe(e) {
|
|
325
|
+
return !!e && typeof e == "object" && "id" in e && typeof e.id == "string" && "metadata" in e;
|
|
326
|
+
}
|
|
327
|
+
function z(e) {
|
|
328
|
+
if (!e || typeof e != "object") return !1;
|
|
329
|
+
let t = e;
|
|
330
|
+
return typeof t.epoch == "string" && [
|
|
331
|
+
t.cursor,
|
|
332
|
+
t.capacity,
|
|
333
|
+
t.evicted,
|
|
334
|
+
t.dropped
|
|
335
|
+
].every(B) && (t.persistenceFailed === void 0 || typeof t.persistenceFailed == "boolean") && (t.nextCursor == null || typeof t.nextCursor == "string") && (t.resumeCursor === void 0 || typeof t.resumeCursor == "string") && (t.reset === void 0 || typeof t.reset == "boolean") && t.capacity > 0 && t.capacity <= 500 && Array.isArray(t.records) && t.records.length <= t.capacity && t.records.every((e) => V(e) && e.sequence <= t.cursor);
|
|
336
|
+
}
|
|
337
|
+
function B(e) {
|
|
338
|
+
return Number.isSafeInteger(e) && Number(e) >= 0;
|
|
339
|
+
}
|
|
340
|
+
function V(e) {
|
|
341
|
+
if (!e || typeof e != "object") return !1;
|
|
342
|
+
let t = e;
|
|
343
|
+
return [
|
|
344
|
+
t.requestId,
|
|
345
|
+
t.hostId,
|
|
346
|
+
t.sessionId,
|
|
347
|
+
t.actorType,
|
|
348
|
+
t.actorId,
|
|
349
|
+
t.operation
|
|
350
|
+
].every((e) => typeof e == "string") && (t.eventId === void 0 || typeof t.eventId == "string" && t.eventId.length > 0) && B(t.sequence) && B(t.startedAtMs) && t.startedAtMs <= 864e13 && ["method", "websocket"].includes(t.kind) && [
|
|
351
|
+
"completed",
|
|
352
|
+
"failed",
|
|
353
|
+
"rejected",
|
|
354
|
+
"rerouted",
|
|
355
|
+
"interrupted"
|
|
356
|
+
].includes(t.outcome) && (t.connectionId === null || typeof t.connectionId == "string") && Number.isFinite(t.durationMs) && t.durationMs >= 0 && (t.queueWaitMs === null || Number.isFinite(t.queueWaitMs) && t.queueWaitMs >= 0 && t.queueWaitMs <= t.durationMs);
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/request-sql.ts
|
|
360
|
+
var H = 100;
|
|
361
|
+
function U(e, t) {
|
|
362
|
+
let n = [], r = [];
|
|
363
|
+
for (let [t, i, a] of [
|
|
364
|
+
[
|
|
365
|
+
"started_at_ms",
|
|
366
|
+
">=",
|
|
367
|
+
e.fromMs
|
|
368
|
+
],
|
|
369
|
+
[
|
|
370
|
+
"started_at_ms",
|
|
371
|
+
"<=",
|
|
372
|
+
e.toMs
|
|
373
|
+
],
|
|
374
|
+
[
|
|
375
|
+
"actor_type",
|
|
376
|
+
"=",
|
|
377
|
+
e.actorType
|
|
378
|
+
],
|
|
379
|
+
[
|
|
380
|
+
"actor_id",
|
|
381
|
+
"=",
|
|
382
|
+
e.actorId
|
|
383
|
+
],
|
|
384
|
+
[
|
|
385
|
+
"outcome",
|
|
386
|
+
"=",
|
|
387
|
+
e.outcome
|
|
388
|
+
]
|
|
389
|
+
]) a !== void 0 && (n.push(`${t} ${i} ?`), r.push(a));
|
|
390
|
+
if (t) {
|
|
391
|
+
let e = JSON.parse(t);
|
|
392
|
+
n.push("sequence <= ?", "(started_at_ms, sequence) < (?, ?)"), r.push(e.watermark, e.time, e.sequence);
|
|
393
|
+
}
|
|
394
|
+
return {
|
|
395
|
+
sql: `SELECT h.generation, h.watermark, h.pruned, h.total, r.sequence, r.event
|
|
396
|
+
FROM request_history h LEFT JOIN (
|
|
397
|
+
SELECT sequence, event, started_at_ms FROM request_events
|
|
398
|
+
${n.length ? `WHERE ${n.join(" AND ")}` : ""}
|
|
399
|
+
ORDER BY started_at_ms DESC, sequence DESC LIMIT 101
|
|
400
|
+
) r ON 1 = 1
|
|
401
|
+
ORDER BY r.started_at_ms DESC, r.sequence DESC`,
|
|
402
|
+
params: r
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function W(e, t) {
|
|
406
|
+
if (e.truncated) throw Error("History query exceeded the server result limit");
|
|
407
|
+
let n = e.rows[0];
|
|
408
|
+
if (!n || typeof n.generation != "string" || ![
|
|
409
|
+
n.watermark,
|
|
410
|
+
n.pruned,
|
|
411
|
+
n.total
|
|
412
|
+
].every((e) => Number.isSafeInteger(e) && Number(e) >= 0)) throw Error("Invalid history metadata");
|
|
413
|
+
let r = t ? JSON.parse(t) : void 0, i = e.rows.filter((e) => e.sequence !== null).map((e) => {
|
|
414
|
+
if (typeof e.event != "string") throw Error("Invalid saved event");
|
|
415
|
+
let t = {
|
|
416
|
+
...JSON.parse(e.event),
|
|
417
|
+
sequence: e.sequence
|
|
418
|
+
};
|
|
419
|
+
if (!V(t)) throw Error("Invalid saved event");
|
|
420
|
+
return t;
|
|
421
|
+
}), a = i.length > H;
|
|
422
|
+
i.length = Math.min(i.length, H);
|
|
423
|
+
let o = i.at(-1), s = r?.watermark ?? Number(n.watermark);
|
|
424
|
+
return {
|
|
425
|
+
epoch: n.generation,
|
|
426
|
+
cursor: Number(n.watermark),
|
|
427
|
+
capacity: H,
|
|
428
|
+
dropped: 0,
|
|
429
|
+
evicted: 0,
|
|
430
|
+
records: i,
|
|
431
|
+
reset: !!r && (r.generation !== n.generation || r.pruned < Number(n.pruned)),
|
|
432
|
+
nextCursor: a && o ? JSON.stringify({
|
|
433
|
+
watermark: s,
|
|
434
|
+
sequence: o.sequence,
|
|
435
|
+
time: o.startedAtMs,
|
|
436
|
+
generation: n.generation,
|
|
437
|
+
pruned: Number(n.pruned)
|
|
438
|
+
}) : null
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/request-history.ts
|
|
443
|
+
function G(t, n) {
|
|
444
|
+
let [a, o] = i(), [s, c] = i(!1), [l, u] = i(!1), d = r(() => {});
|
|
445
|
+
return e(() => {
|
|
446
|
+
if (o(void 0), u(!1), c(!1), !n) return;
|
|
447
|
+
let e = new AbortController(), r = !1;
|
|
448
|
+
d.current = (t) => {
|
|
449
|
+
r || e.signal.aborted || (r = !0, c(!0), u(!1), i(t));
|
|
450
|
+
};
|
|
451
|
+
async function i(i) {
|
|
452
|
+
try {
|
|
453
|
+
if (!t.query) throw Error("History is unavailable");
|
|
454
|
+
let r = W(await t.query(U(n, i), e.signal), i);
|
|
455
|
+
if (e.signal.aborted) return;
|
|
456
|
+
o((e) => {
|
|
457
|
+
if (!i || !e || e.epoch !== r.epoch) return r;
|
|
458
|
+
let t = new Map(e.records.map((e) => [e.eventId ?? e.sequence, e]));
|
|
459
|
+
for (let e of r.records) t.set(e.eventId ?? e.sequence, e);
|
|
460
|
+
return {
|
|
461
|
+
...r,
|
|
462
|
+
reset: e.reset || r.reset,
|
|
463
|
+
records: [...t.values()]
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
} catch {
|
|
467
|
+
e.signal.aborted || u(!0);
|
|
468
|
+
} finally {
|
|
469
|
+
r = !1, e.signal.aborted || c(!1);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return d.current(), () => e.abort();
|
|
473
|
+
}, [t, n]), {
|
|
474
|
+
page: a,
|
|
475
|
+
loading: s,
|
|
476
|
+
failed: l,
|
|
477
|
+
loadOlder: () => d.current(a?.nextCursor ?? void 0),
|
|
478
|
+
retry: () => d.current(a?.nextCursor ?? void 0)
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/RequestObserver.tsx
|
|
483
|
+
function K({ client: t, actor: a }) {
|
|
484
|
+
let [o, u] = i(), d = G(t, n(() => o ? {
|
|
485
|
+
...o,
|
|
486
|
+
...a
|
|
487
|
+
} : void 0, [
|
|
488
|
+
o,
|
|
489
|
+
a?.actorType,
|
|
490
|
+
a?.actorId
|
|
491
|
+
])), { page: f, failed: p, retry: m } = re(t), [h, y] = i(), [b, x] = i(), S = r(null), C = r(null), w = a ? "h3" : "h1", E = o ? d.page : h ?? f, O = f ?? d.page, I = (E?.records ?? []).filter((e) => !a || e.actorType === a.actorType && e.actorId === a.actorId);
|
|
492
|
+
return e(() => {
|
|
493
|
+
y(void 0), u(void 0);
|
|
494
|
+
}, [
|
|
495
|
+
t,
|
|
496
|
+
a?.actorType,
|
|
497
|
+
a?.actorId
|
|
498
|
+
]), e(() => x(void 0), [
|
|
499
|
+
t,
|
|
500
|
+
f?.epoch,
|
|
501
|
+
o,
|
|
502
|
+
a?.actorType,
|
|
503
|
+
a?.actorId
|
|
504
|
+
]), /* @__PURE__ */ v("section", {
|
|
505
|
+
ref: S,
|
|
506
|
+
className: "la-observer la-requests",
|
|
507
|
+
"aria-label": "Request observer",
|
|
508
|
+
children: [
|
|
509
|
+
/* @__PURE__ */ v("div", {
|
|
510
|
+
className: "la-observer-toolbar",
|
|
511
|
+
children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _(w, { children: "Requests" }), /* @__PURE__ */ _("p", { children: a ? "Method calls and WebSocket events for this instance." : "Method calls and WebSocket events, with time spent waiting and processing." })] }), /* @__PURE__ */ v("div", {
|
|
512
|
+
className: "la-request-actions",
|
|
513
|
+
children: [t.query && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(D, {
|
|
514
|
+
variant: o ? "outline" : "secondary",
|
|
515
|
+
"aria-pressed": !o,
|
|
516
|
+
onClick: () => {
|
|
517
|
+
u(void 0), y(void 0);
|
|
518
|
+
},
|
|
519
|
+
children: "Live"
|
|
520
|
+
}), /* @__PURE__ */ _(D, {
|
|
521
|
+
variant: o ? "secondary" : "outline",
|
|
522
|
+
"aria-pressed": !!o,
|
|
523
|
+
onClick: () => {
|
|
524
|
+
o || u({});
|
|
525
|
+
},
|
|
526
|
+
children: "History"
|
|
527
|
+
})] }), !o && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v(D, {
|
|
528
|
+
variant: "outline",
|
|
529
|
+
disabled: !E,
|
|
530
|
+
onClick: () => y(h ? void 0 : f),
|
|
531
|
+
children: [_(h ? c : s, { "aria-hidden": "true" }), h ? "Resume" : "Pause"]
|
|
532
|
+
}), p && /* @__PURE__ */ v(D, {
|
|
533
|
+
variant: "outline",
|
|
534
|
+
onClick: m,
|
|
535
|
+
children: [/* @__PURE__ */ _(l, { "aria-hidden": "true" }), "Retry"]
|
|
536
|
+
})] })]
|
|
537
|
+
})]
|
|
538
|
+
}),
|
|
539
|
+
o && /* @__PURE__ */ _(se, {
|
|
540
|
+
query: o,
|
|
541
|
+
loading: d.loading,
|
|
542
|
+
onSearch: u,
|
|
543
|
+
scoped: !!a
|
|
544
|
+
}),
|
|
545
|
+
o && d.failed && /* @__PURE__ */ v("div", {
|
|
546
|
+
className: "la-observer-error",
|
|
547
|
+
role: "alert",
|
|
548
|
+
children: [
|
|
549
|
+
"Request history unavailable.",
|
|
550
|
+
" ",
|
|
551
|
+
/* @__PURE__ */ _(D, {
|
|
552
|
+
variant: "outline",
|
|
553
|
+
onClick: d.retry,
|
|
554
|
+
children: "Retry history"
|
|
555
|
+
})
|
|
556
|
+
]
|
|
557
|
+
}),
|
|
558
|
+
!o && p && /* @__PURE__ */ v("div", {
|
|
559
|
+
className: "la-observer-error",
|
|
560
|
+
role: "alert",
|
|
561
|
+
children: ["Request stream disconnected. Reconnecting… ", f ? "Showing the last received requests." : "Check your connection and runtime version."]
|
|
562
|
+
}),
|
|
563
|
+
!!O?.dropped && /* @__PURE__ */ v("div", {
|
|
564
|
+
className: "la-observer-error",
|
|
565
|
+
role: "alert",
|
|
566
|
+
children: [O.dropped.toLocaleString(), " request traces were not delivered. This history is incomplete."]
|
|
567
|
+
}),
|
|
568
|
+
O?.persistenceFailed && /* @__PURE__ */ _("div", {
|
|
569
|
+
className: "la-observer-error",
|
|
570
|
+
role: "alert",
|
|
571
|
+
children: "Some request events could not be saved. This history may be incomplete."
|
|
572
|
+
}),
|
|
573
|
+
E?.reset && /* @__PURE__ */ _("div", {
|
|
574
|
+
className: "la-observer-error",
|
|
575
|
+
role: "alert",
|
|
576
|
+
children: "Some older events are no longer retained. Showing available history."
|
|
577
|
+
}),
|
|
578
|
+
/* @__PURE__ */ v("div", {
|
|
579
|
+
className: "la-observer-table-frame",
|
|
580
|
+
children: [/* @__PURE__ */ v(A, {
|
|
581
|
+
"aria-label": o ? "Saved requests" : "Recent requests",
|
|
582
|
+
className: "la-request-table",
|
|
583
|
+
children: [/* @__PURE__ */ _(j, { children: /* @__PURE__ */ v(N, { children: [
|
|
584
|
+
/* @__PURE__ */ _(P, {
|
|
585
|
+
scope: "col",
|
|
586
|
+
children: "Time"
|
|
587
|
+
}),
|
|
588
|
+
/* @__PURE__ */ _(P, {
|
|
589
|
+
scope: "col",
|
|
590
|
+
children: "Request"
|
|
591
|
+
}),
|
|
592
|
+
/* @__PURE__ */ _(P, {
|
|
593
|
+
scope: "col",
|
|
594
|
+
children: "Instance"
|
|
595
|
+
}),
|
|
596
|
+
/* @__PURE__ */ _(P, {
|
|
597
|
+
scope: "col",
|
|
598
|
+
children: "Transport"
|
|
599
|
+
}),
|
|
600
|
+
/* @__PURE__ */ _(P, {
|
|
601
|
+
scope: "col",
|
|
602
|
+
children: "Outcome"
|
|
603
|
+
}),
|
|
604
|
+
/* @__PURE__ */ _(P, {
|
|
605
|
+
scope: "col",
|
|
606
|
+
children: "Total"
|
|
607
|
+
}),
|
|
608
|
+
/* @__PURE__ */ _(P, {
|
|
609
|
+
scope: "col",
|
|
610
|
+
children: "Queue wait"
|
|
611
|
+
}),
|
|
612
|
+
/* @__PURE__ */ _(P, {
|
|
613
|
+
scope: "col",
|
|
614
|
+
children: /* @__PURE__ */ _("span", {
|
|
615
|
+
className: "la:sr-only",
|
|
616
|
+
children: "Details"
|
|
617
|
+
})
|
|
618
|
+
})
|
|
619
|
+
] }) }), /* @__PURE__ */ _(M, { children: I.map((e) => /* @__PURE__ */ v(N, {
|
|
620
|
+
className: "la-clickable-row",
|
|
621
|
+
"data-state": b === e ? "selected" : void 0,
|
|
622
|
+
onClick: (t) => {
|
|
623
|
+
C.current = t.currentTarget.querySelector("button"), x(e);
|
|
624
|
+
},
|
|
625
|
+
children: [
|
|
626
|
+
/* @__PURE__ */ _(F, { children: /* @__PURE__ */ _("time", {
|
|
627
|
+
dateTime: new Date(e.startedAtMs).toISOString(),
|
|
628
|
+
title: new Date(e.startedAtMs).toLocaleString(),
|
|
629
|
+
children: o ? new Date(e.startedAtMs).toLocaleString([], { hour12: !1 }) : new Date(e.startedAtMs).toLocaleTimeString([], { hour12: !1 })
|
|
630
|
+
}) }),
|
|
631
|
+
/* @__PURE__ */ _(F, { children: /* @__PURE__ */ _("span", {
|
|
632
|
+
className: "la-request-operation",
|
|
633
|
+
title: e.operation,
|
|
634
|
+
children: e.operation
|
|
635
|
+
}) }),
|
|
636
|
+
/* @__PURE__ */ _(F, { children: /* @__PURE__ */ v("span", {
|
|
637
|
+
className: "la-request-actor",
|
|
638
|
+
title: `${e.actorType} / ${e.actorId}`,
|
|
639
|
+
children: [
|
|
640
|
+
e.actorType,
|
|
641
|
+
" / ",
|
|
642
|
+
e.actorId
|
|
643
|
+
]
|
|
644
|
+
}) }),
|
|
645
|
+
/* @__PURE__ */ _(F, { children: e.kind === "method" ? "Method" : "WebSocket" }),
|
|
646
|
+
/* @__PURE__ */ _(F, { children: /* @__PURE__ */ _(T, {
|
|
647
|
+
variant: "outline",
|
|
648
|
+
className: `la-request-outcome-${e.outcome}`,
|
|
649
|
+
children: e.outcome[0].toUpperCase() + e.outcome.slice(1)
|
|
650
|
+
}) }),
|
|
651
|
+
/* @__PURE__ */ _(F, { children: q(e.durationMs) }),
|
|
652
|
+
/* @__PURE__ */ _(F, { children: e.queueWaitMs === null ? /* @__PURE__ */ _("span", {
|
|
653
|
+
title: "Request did not begin processing",
|
|
654
|
+
children: "—"
|
|
655
|
+
}) : q(e.queueWaitMs) }),
|
|
656
|
+
/* @__PURE__ */ _(F, { children: /* @__PURE__ */ _(D, {
|
|
657
|
+
variant: "ghost",
|
|
658
|
+
size: "sm",
|
|
659
|
+
"aria-label": `Inspect ${e.operation} request`,
|
|
660
|
+
"aria-haspopup": "dialog",
|
|
661
|
+
children: "Details"
|
|
662
|
+
}) })
|
|
663
|
+
]
|
|
664
|
+
}, e.eventId ?? `${E.epoch}-${e.sequence}`)) })]
|
|
665
|
+
}), !I.length && /* @__PURE__ */ v("div", {
|
|
666
|
+
className: "la-request-empty",
|
|
667
|
+
role: "status",
|
|
668
|
+
children: [/* @__PURE__ */ _("strong", { children: o ? d.loading ? "Loading history…" : d.failed ? "History unavailable" : "No saved requests in this range" : E ? "No requests yet" : p ? "Requests unavailable" : "Connecting to requests…" }), /* @__PURE__ */ _("p", { children: o ? "Try a wider time range or fewer filters. Local history retains the latest 10,000 events." : "Call an actor method or send a WebSocket message to see its timings." })]
|
|
669
|
+
})]
|
|
670
|
+
}),
|
|
671
|
+
o && E?.nextCursor && /* @__PURE__ */ _(D, {
|
|
672
|
+
className: "la-request-load-older",
|
|
673
|
+
variant: "outline",
|
|
674
|
+
disabled: d.loading,
|
|
675
|
+
onClick: d.loadOlder,
|
|
676
|
+
children: d.loading ? "Loading…" : "Load older"
|
|
677
|
+
}),
|
|
678
|
+
/* @__PURE__ */ v("div", {
|
|
679
|
+
className: "la-observer-footnote",
|
|
680
|
+
children: [/* @__PURE__ */ v("span", {
|
|
681
|
+
className: "la-observer-refresh-status",
|
|
682
|
+
children: [!o && /* @__PURE__ */ _("span", { className: `la-observer-dot ${p ? "la-observer-dot-unknown" : "la-observer-dot-live"}` }), o ? "Saved history" : h ? "Display paused · collection continues" : p ? "Reconnecting…" : f ? "Live updates" : "Connecting…"]
|
|
683
|
+
}), /* @__PURE__ */ _("span", { children: o ? `${I.length.toLocaleString()} saved requests shown` : a ? `${I.length} matching requests from the latest ${E?.capacity ?? 500} on this control plane.` : `Latest ${E?.capacity ?? 500} requests on this control plane.` })]
|
|
684
|
+
}),
|
|
685
|
+
!o && !!E?.evicted && /* @__PURE__ */ v("p", {
|
|
686
|
+
className: "la-request-note",
|
|
687
|
+
children: [E.evicted.toLocaleString(), " older records have left this history window."]
|
|
688
|
+
}),
|
|
689
|
+
/* @__PURE__ */ _("p", {
|
|
690
|
+
className: "la-request-note",
|
|
691
|
+
children: "Total includes queue wait, actor processing, and persistence. Queue wait includes the WebSocket message queue. Timings exclude the caller’s network round trip."
|
|
692
|
+
}),
|
|
693
|
+
/* @__PURE__ */ _(ee, {
|
|
694
|
+
open: !!b,
|
|
695
|
+
onOpenChange: (e) => {
|
|
696
|
+
e || x(void 0);
|
|
697
|
+
},
|
|
698
|
+
children: /* @__PURE__ */ v(ne, {
|
|
699
|
+
container: S.current,
|
|
700
|
+
onCloseAutoFocus: (e) => {
|
|
701
|
+
e.preventDefault(), C.current?.focus();
|
|
702
|
+
},
|
|
703
|
+
children: [
|
|
704
|
+
/* @__PURE__ */ _(te, { children: "Request details" }),
|
|
705
|
+
/* @__PURE__ */ _(k, { children: "Full identifiers and timings for this request." }),
|
|
706
|
+
b && /* @__PURE__ */ _(ce, { record: b })
|
|
707
|
+
]
|
|
708
|
+
})
|
|
709
|
+
})
|
|
710
|
+
]
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
function se({ query: e, loading: t, onSearch: n, scoped: r }) {
|
|
714
|
+
let [a, o] = i(!1);
|
|
715
|
+
return /* @__PURE__ */ v("form", {
|
|
716
|
+
className: "la-request-history-filters",
|
|
717
|
+
onSubmit: (e) => {
|
|
718
|
+
e.preventDefault();
|
|
719
|
+
let t = new FormData(e.currentTarget), r = t.get("from") ? new Date(String(t.get("from"))).getTime() : void 0, i = t.get("to") ? new Date(String(t.get("to"))).getTime() : void 0;
|
|
720
|
+
if (r !== void 0 && i !== void 0 && r > i) {
|
|
721
|
+
o(!0);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
o(!1), n({
|
|
725
|
+
fromMs: r,
|
|
726
|
+
toMs: i,
|
|
727
|
+
actorId: String(t.get("actorId") || "").trim() || void 0,
|
|
728
|
+
outcome: String(t.get("outcome") || "") || void 0
|
|
729
|
+
});
|
|
730
|
+
},
|
|
731
|
+
children: [
|
|
732
|
+
/* @__PURE__ */ v("label", { children: ["From", /* @__PURE__ */ _(O, {
|
|
733
|
+
type: "datetime-local",
|
|
734
|
+
name: "from"
|
|
735
|
+
})] }),
|
|
736
|
+
/* @__PURE__ */ v("label", { children: ["To", /* @__PURE__ */ _(O, {
|
|
737
|
+
type: "datetime-local",
|
|
738
|
+
name: "to"
|
|
739
|
+
})] }),
|
|
740
|
+
!r && /* @__PURE__ */ v("label", { children: ["Actor ID", /* @__PURE__ */ _(O, {
|
|
741
|
+
name: "actorId",
|
|
742
|
+
placeholder: "All actors",
|
|
743
|
+
maxLength: 256,
|
|
744
|
+
defaultValue: e.actorId
|
|
745
|
+
})] }),
|
|
746
|
+
/* @__PURE__ */ v("label", { children: ["Outcome", /* @__PURE__ */ v("select", {
|
|
747
|
+
className: "la-observer-select",
|
|
748
|
+
name: "outcome",
|
|
749
|
+
defaultValue: e.outcome ?? "",
|
|
750
|
+
children: [/* @__PURE__ */ _("option", {
|
|
751
|
+
value: "",
|
|
752
|
+
children: "All outcomes"
|
|
753
|
+
}), [
|
|
754
|
+
"completed",
|
|
755
|
+
"failed",
|
|
756
|
+
"rejected",
|
|
757
|
+
"rerouted",
|
|
758
|
+
"interrupted"
|
|
759
|
+
].map((e) => /* @__PURE__ */ _("option", {
|
|
760
|
+
value: e,
|
|
761
|
+
children: e[0].toUpperCase() + e.slice(1)
|
|
762
|
+
}, e))]
|
|
763
|
+
})] }),
|
|
764
|
+
/* @__PURE__ */ _(D, {
|
|
765
|
+
type: "submit",
|
|
766
|
+
variant: "outline",
|
|
767
|
+
disabled: t,
|
|
768
|
+
children: "Search"
|
|
769
|
+
}),
|
|
770
|
+
a && /* @__PURE__ */ _("p", {
|
|
771
|
+
className: "la-observer-error",
|
|
772
|
+
role: "alert",
|
|
773
|
+
children: "From must be before To."
|
|
774
|
+
})
|
|
775
|
+
]
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
function ce({ record: e }) {
|
|
779
|
+
let t = {
|
|
780
|
+
Operation: e.operation,
|
|
781
|
+
"Actor class": e.actorType,
|
|
782
|
+
"Instance ID": e.actorId,
|
|
783
|
+
"Request ID": e.requestId,
|
|
784
|
+
Time: new Date(e.startedAtMs).toLocaleString(),
|
|
785
|
+
Transport: e.kind === "method" ? "Method" : "WebSocket",
|
|
786
|
+
Outcome: e.outcome,
|
|
787
|
+
Total: q(e.durationMs),
|
|
788
|
+
"Queue wait": e.queueWaitMs === null ? "Did not begin processing" : q(e.queueWaitMs),
|
|
789
|
+
Host: e.hostId,
|
|
790
|
+
...e.connectionId ? { Connection: e.connectionId } : {}
|
|
791
|
+
};
|
|
792
|
+
return /* @__PURE__ */ _("dl", {
|
|
793
|
+
className: "la-request-details",
|
|
794
|
+
children: Object.entries(t).map(([e, t]) => /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", { children: e }), /* @__PURE__ */ _("dd", { children: t })] }, e))
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
function q(e) {
|
|
798
|
+
return e >= 1e3 ? `${(e / 1e3).toLocaleString(void 0, { maximumFractionDigits: 2 })} s` : `${e.toLocaleString(void 0, { maximumFractionDigits: 1 })} ms`;
|
|
799
|
+
}
|
|
800
|
+
//#endregion
|
|
801
|
+
//#region src/ActorObserver.tsx
|
|
802
|
+
function le({ client: n, className: a = "", initialActorType: s, navigation: c }) {
|
|
803
|
+
let { inventory: u, loading: d, failed: f, retry: p } = I(n), [m, h] = i(s), y = c ? c.actorType : m, b = c ? c.onSelectActor : h, [x, S] = i(""), C = r(null), w = r(s), T = t(), E = u?.actors.find((e) => e.actorType === y);
|
|
804
|
+
return e(() => {
|
|
805
|
+
h(s), S("");
|
|
806
|
+
}, [n, s]), e(() => {
|
|
807
|
+
w.current !== y && C.current?.focus(), w.current = y;
|
|
808
|
+
}, [y]), /* @__PURE__ */ v("section", {
|
|
809
|
+
className: `la-observer ${a}`,
|
|
810
|
+
"aria-label": "Actor observer",
|
|
811
|
+
children: [
|
|
812
|
+
y !== void 0 && /* @__PURE__ */ v("nav", {
|
|
813
|
+
className: "la-observer-breadcrumb",
|
|
814
|
+
"aria-label": "Breadcrumb",
|
|
815
|
+
children: [
|
|
816
|
+
/* @__PURE__ */ _(D, {
|
|
817
|
+
variant: "link",
|
|
818
|
+
type: "button",
|
|
819
|
+
"aria-label": "Back to actors",
|
|
820
|
+
onClick: () => b(void 0),
|
|
821
|
+
children: "Actors"
|
|
822
|
+
}),
|
|
823
|
+
/* @__PURE__ */ _("span", {
|
|
824
|
+
"aria-hidden": "true",
|
|
825
|
+
children: "/"
|
|
826
|
+
}),
|
|
827
|
+
/* @__PURE__ */ _("span", {
|
|
828
|
+
"aria-current": "page",
|
|
829
|
+
children: y
|
|
830
|
+
})
|
|
831
|
+
]
|
|
832
|
+
}),
|
|
833
|
+
/* @__PURE__ */ v("div", {
|
|
834
|
+
className: "la-observer-toolbar",
|
|
835
|
+
children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("div", {
|
|
836
|
+
className: "la-observer-title",
|
|
837
|
+
children: /* @__PURE__ */ _("h1", {
|
|
838
|
+
ref: C,
|
|
839
|
+
tabIndex: -1,
|
|
840
|
+
children: y ?? "Actors"
|
|
841
|
+
})
|
|
842
|
+
}), /* @__PURE__ */ _("p", { children: y === void 0 ? "Inspect instances, residency, and connections." : "Inspect this actor class’s instances, residency, and connections." })] }), /* @__PURE__ */ v(D, {
|
|
843
|
+
variant: "outline",
|
|
844
|
+
type: "button",
|
|
845
|
+
disabled: d,
|
|
846
|
+
onClick: p,
|
|
847
|
+
children: [/* @__PURE__ */ _(l, {
|
|
848
|
+
"aria-hidden": "true",
|
|
849
|
+
className: d ? "la-observer-spin" : void 0
|
|
850
|
+
}), d ? "Refreshing…" : f ? "Try again" : "Refresh"]
|
|
851
|
+
})]
|
|
852
|
+
}),
|
|
853
|
+
f && /* @__PURE__ */ v("div", {
|
|
854
|
+
className: "la-observer-error",
|
|
855
|
+
role: "alert",
|
|
856
|
+
children: [/* @__PURE__ */ _(o, { "aria-hidden": "true" }), /* @__PURE__ */ _("p", { children: u ? "Could not refresh. These counts may be out of date." : "Could not load actors. Check your connection and access, then try again." })]
|
|
857
|
+
}),
|
|
858
|
+
!u && !f && /* @__PURE__ */ _(ue, {}),
|
|
859
|
+
u && /* @__PURE__ */ v(g, { children: [y === void 0 ? /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(J, { inventory: u }), u.actors.length ? /* @__PURE__ */ _(de, {
|
|
860
|
+
inventory: u,
|
|
861
|
+
query: x,
|
|
862
|
+
onQueryChange: S,
|
|
863
|
+
onSelectActor: b
|
|
864
|
+
}) : /* @__PURE__ */ _(Z, {
|
|
865
|
+
title: "No actors yet",
|
|
866
|
+
description: "Deploy your actor classes to see them here. Instance counts appear as actors are used."
|
|
867
|
+
})] }) : E ? /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(J, {
|
|
868
|
+
inventory: { actors: [E] },
|
|
869
|
+
actorType: y
|
|
870
|
+
}), /* @__PURE__ */ _(fe, {
|
|
871
|
+
client: n,
|
|
872
|
+
id: T,
|
|
873
|
+
actorType: y,
|
|
874
|
+
instances: E.instances
|
|
875
|
+
}, y)] }) : /* @__PURE__ */ _(Z, {
|
|
876
|
+
title: "Actor class unavailable",
|
|
877
|
+
description: "This actor class is no longer in the latest inventory. Return to Actors to see available classes."
|
|
878
|
+
}), /* @__PURE__ */ v("div", {
|
|
879
|
+
className: "la-observer-footnote",
|
|
880
|
+
children: [/* @__PURE__ */ v("span", {
|
|
881
|
+
className: "la-observer-refresh-status",
|
|
882
|
+
children: [/* @__PURE__ */ _("span", { className: `la-observer-dot ${f ? "la-observer-dot-unknown" : n.watchActors ? "la-observer-dot-live" : ""}` }), f ? "Reconnecting…" : n.watchActors ? "Live updates" : "Auto-refresh every 5s"]
|
|
883
|
+
}), /* @__PURE__ */ _("span", { children: n.watchActors ? "Changes stream from the control plane." : "Counts follow the latest host heartbeat." })]
|
|
884
|
+
})] })
|
|
885
|
+
]
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function ue() {
|
|
889
|
+
return /* @__PURE__ */ v("div", {
|
|
890
|
+
className: "la-observer-skeleton",
|
|
891
|
+
role: "status",
|
|
892
|
+
"aria-label": "Loading actors",
|
|
893
|
+
children: [
|
|
894
|
+
/* @__PURE__ */ _("span", {
|
|
895
|
+
className: "la:sr-only",
|
|
896
|
+
children: "Loading actors…"
|
|
897
|
+
}),
|
|
898
|
+
/* @__PURE__ */ _("div", {}),
|
|
899
|
+
/* @__PURE__ */ _("div", {}),
|
|
900
|
+
/* @__PURE__ */ _("div", {})
|
|
901
|
+
]
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
function J({ inventory: e, actorType: t }) {
|
|
905
|
+
let n = e.actors.reduce((e, t) => ({
|
|
906
|
+
live: e.live + t.live,
|
|
907
|
+
dormant: e.dormant + t.dormant,
|
|
908
|
+
unknown: e.unknown + t.unknown
|
|
909
|
+
}), {
|
|
910
|
+
live: 0,
|
|
911
|
+
dormant: 0,
|
|
912
|
+
unknown: 0
|
|
913
|
+
});
|
|
914
|
+
return /* @__PURE__ */ v("dl", {
|
|
915
|
+
className: "la-observer-summary",
|
|
916
|
+
children: [
|
|
917
|
+
/* @__PURE__ */ v("div", { children: [
|
|
918
|
+
/* @__PURE__ */ _("dt", { children: "Total instances" }),
|
|
919
|
+
/* @__PURE__ */ _("dd", {
|
|
920
|
+
"aria-label": "Total instances",
|
|
921
|
+
children: (n.live + n.dormant + n.unknown).toLocaleString()
|
|
922
|
+
}),
|
|
923
|
+
/* @__PURE__ */ _("p", { children: t === void 0 ? `${e.actors.length} actor ${e.actors.length === 1 ? "type" : "types"}` : "In this actor class" })
|
|
924
|
+
] }),
|
|
925
|
+
/* @__PURE__ */ v("div", { children: [
|
|
926
|
+
/* @__PURE__ */ v("dt", { children: [/* @__PURE__ */ _("span", { className: "la-observer-dot la-observer-dot-live" }), "Live"] }),
|
|
927
|
+
/* @__PURE__ */ _("dd", {
|
|
928
|
+
"aria-label": "Live instances",
|
|
929
|
+
children: n.live.toLocaleString()
|
|
930
|
+
}),
|
|
931
|
+
/* @__PURE__ */ _("p", { children: "Loaded in memory" })
|
|
932
|
+
] }),
|
|
933
|
+
/* @__PURE__ */ v("div", { children: [
|
|
934
|
+
/* @__PURE__ */ v("dt", { children: [/* @__PURE__ */ _("span", { className: "la-observer-dot" }), "Dormant"] }),
|
|
935
|
+
/* @__PURE__ */ _("dd", {
|
|
936
|
+
"aria-label": "Dormant instances",
|
|
937
|
+
children: n.dormant.toLocaleString()
|
|
938
|
+
}),
|
|
939
|
+
/* @__PURE__ */ _("p", { children: "Currently unloaded" })
|
|
940
|
+
] }),
|
|
941
|
+
n.unknown > 0 && /* @__PURE__ */ v("div", { children: [
|
|
942
|
+
/* @__PURE__ */ v("dt", { children: [/* @__PURE__ */ _("span", { className: "la-observer-dot la-observer-dot-unknown" }), "Unknown"] }),
|
|
943
|
+
/* @__PURE__ */ _("dd", {
|
|
944
|
+
"aria-label": "Unknown instances",
|
|
945
|
+
children: n.unknown.toLocaleString()
|
|
946
|
+
}),
|
|
947
|
+
/* @__PURE__ */ _("p", { children: "Awaiting host report" })
|
|
948
|
+
] })
|
|
949
|
+
]
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
function de({ inventory: e, query: t, onQueryChange: n, onSelectActor: r }) {
|
|
953
|
+
let i = e.actors.some((e) => e.unknown > 0), s = e.actors.filter((e) => Q(e.actorType, t)).sort((e, t) => Number(t.live > 0) - Number(e.live > 0));
|
|
954
|
+
return /* @__PURE__ */ v(g, { children: [
|
|
955
|
+
/* @__PURE__ */ v("div", {
|
|
956
|
+
className: "la-observer-list-toolbar",
|
|
957
|
+
children: [/* @__PURE__ */ v("h2", { children: ["Actor types ", /* @__PURE__ */ _(T, { children: e.actors.length })] }), /* @__PURE__ */ _(X, {
|
|
958
|
+
label: "Search actors",
|
|
959
|
+
placeholder: "Search actors…",
|
|
960
|
+
value: t,
|
|
961
|
+
onChange: n
|
|
962
|
+
})]
|
|
963
|
+
}),
|
|
964
|
+
/* @__PURE__ */ _("div", {
|
|
965
|
+
className: "la-observer-table-frame",
|
|
966
|
+
children: s.length ? /* @__PURE__ */ v(A, {
|
|
967
|
+
"aria-label": "Actor instance counts",
|
|
968
|
+
className: "la-observer-table",
|
|
969
|
+
children: [/* @__PURE__ */ _(j, { children: /* @__PURE__ */ v(N, { children: [
|
|
970
|
+
/* @__PURE__ */ _(P, {
|
|
971
|
+
scope: "col",
|
|
972
|
+
children: "Actor"
|
|
973
|
+
}),
|
|
974
|
+
/* @__PURE__ */ _(P, {
|
|
975
|
+
scope: "col",
|
|
976
|
+
children: "Live"
|
|
977
|
+
}),
|
|
978
|
+
/* @__PURE__ */ _(P, {
|
|
979
|
+
scope: "col",
|
|
980
|
+
children: "Dormant"
|
|
981
|
+
}),
|
|
982
|
+
i && /* @__PURE__ */ _(P, {
|
|
983
|
+
scope: "col",
|
|
984
|
+
children: "Unknown"
|
|
985
|
+
}),
|
|
986
|
+
/* @__PURE__ */ _(P, {
|
|
987
|
+
scope: "col",
|
|
988
|
+
children: "Total"
|
|
989
|
+
})
|
|
990
|
+
] }) }), /* @__PURE__ */ _(M, { children: s.map((e) => /* @__PURE__ */ v(N, {
|
|
991
|
+
className: "la-clickable-row",
|
|
992
|
+
onClick: () => r(e.actorType),
|
|
993
|
+
children: [
|
|
994
|
+
/* @__PURE__ */ _(F, {
|
|
995
|
+
className: "la-observer-name",
|
|
996
|
+
children: /* @__PURE__ */ v(D, {
|
|
997
|
+
variant: "ghost",
|
|
998
|
+
type: "button",
|
|
999
|
+
className: "la-observer-actor-button la-observer-class-button",
|
|
1000
|
+
children: [/* @__PURE__ */ _(a, {
|
|
1001
|
+
className: "la-observer-type-icon",
|
|
1002
|
+
"aria-hidden": "true"
|
|
1003
|
+
}), /* @__PURE__ */ _("span", { children: e.actorType })]
|
|
1004
|
+
})
|
|
1005
|
+
}),
|
|
1006
|
+
/* @__PURE__ */ _(F, { children: /* @__PURE__ */ _("span", {
|
|
1007
|
+
className: e.live > 0 ? "la-observer-live" : void 0,
|
|
1008
|
+
children: e.live.toLocaleString()
|
|
1009
|
+
}) }),
|
|
1010
|
+
/* @__PURE__ */ _(F, { children: e.dormant.toLocaleString() }),
|
|
1011
|
+
i && /* @__PURE__ */ _(F, { children: e.unknown.toLocaleString() }),
|
|
1012
|
+
/* @__PURE__ */ _(F, { children: (e.live + e.dormant + e.unknown).toLocaleString() })
|
|
1013
|
+
]
|
|
1014
|
+
}, e.actorType)) })]
|
|
1015
|
+
}) : /* @__PURE__ */ _(Z, {
|
|
1016
|
+
title: "No matching actors",
|
|
1017
|
+
description: "Try a different actor name.",
|
|
1018
|
+
action: "Clear search",
|
|
1019
|
+
onReset: () => n("")
|
|
1020
|
+
})
|
|
1021
|
+
}),
|
|
1022
|
+
i && /* @__PURE__ */ v("p", {
|
|
1023
|
+
className: "la-observer-unknown",
|
|
1024
|
+
children: [/* @__PURE__ */ _(o, { "aria-hidden": "true" }), "Some hosts have not reported which instances are loaded. Their counts are shown as unknown."]
|
|
1025
|
+
})
|
|
1026
|
+
] });
|
|
1027
|
+
}
|
|
1028
|
+
function fe({ client: t, id: n, actorType: a, instances: o }) {
|
|
1029
|
+
let [s, c] = i(""), [l, u] = i("all"), [d, f] = i(), p = `${n}-connections`, m = o.filter((e) => Q(e.actorId, s) && (l === "all" || e.status === l));
|
|
1030
|
+
m.sort((e, t) => Number(t.status === "live") - Number(e.status === "live"));
|
|
1031
|
+
let h = o.find((e) => e.actorId === d), y = r(null);
|
|
1032
|
+
return e(() => {
|
|
1033
|
+
y.current?.focus();
|
|
1034
|
+
}, [d]), d === void 0 ? /* @__PURE__ */ v("section", {
|
|
1035
|
+
id: n,
|
|
1036
|
+
className: "la-observer-instances",
|
|
1037
|
+
"aria-labelledby": `${n}-heading`,
|
|
1038
|
+
children: [/* @__PURE__ */ _("div", {
|
|
1039
|
+
className: "la-observer-instances-heading",
|
|
1040
|
+
children: /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ v("h2", {
|
|
1041
|
+
ref: y,
|
|
1042
|
+
tabIndex: -1,
|
|
1043
|
+
id: `${n}-heading`,
|
|
1044
|
+
children: [
|
|
1045
|
+
a,
|
|
1046
|
+
" instances ",
|
|
1047
|
+
/* @__PURE__ */ _(T, {
|
|
1048
|
+
"aria-hidden": "true",
|
|
1049
|
+
children: o.length.toLocaleString()
|
|
1050
|
+
})
|
|
1051
|
+
]
|
|
1052
|
+
}), /* @__PURE__ */ _("p", { children: "Select an instance to inspect its waiting line, requests, and WebSocket connections." })] })
|
|
1053
|
+
}), o.length ? /* @__PURE__ */ v(g, { children: [
|
|
1054
|
+
/* @__PURE__ */ v("div", {
|
|
1055
|
+
className: "la-observer-filters",
|
|
1056
|
+
children: [/* @__PURE__ */ _(X, {
|
|
1057
|
+
label: "Search instances",
|
|
1058
|
+
placeholder: "Search instance IDs…",
|
|
1059
|
+
value: s,
|
|
1060
|
+
onChange: c
|
|
1061
|
+
}), /* @__PURE__ */ v("select", {
|
|
1062
|
+
className: "la-observer-select",
|
|
1063
|
+
"aria-label": "Instance state",
|
|
1064
|
+
value: l,
|
|
1065
|
+
onChange: (e) => u(e.target.value),
|
|
1066
|
+
children: [
|
|
1067
|
+
/* @__PURE__ */ _("option", {
|
|
1068
|
+
value: "all",
|
|
1069
|
+
children: "All states"
|
|
1070
|
+
}),
|
|
1071
|
+
/* @__PURE__ */ _("option", {
|
|
1072
|
+
value: "live",
|
|
1073
|
+
children: "Live"
|
|
1074
|
+
}),
|
|
1075
|
+
/* @__PURE__ */ _("option", {
|
|
1076
|
+
value: "dormant",
|
|
1077
|
+
children: "Dormant"
|
|
1078
|
+
}),
|
|
1079
|
+
/* @__PURE__ */ _("option", {
|
|
1080
|
+
value: "unknown",
|
|
1081
|
+
children: "Unknown"
|
|
1082
|
+
})
|
|
1083
|
+
]
|
|
1084
|
+
})]
|
|
1085
|
+
}),
|
|
1086
|
+
/* @__PURE__ */ _("div", {
|
|
1087
|
+
className: "la-observer-table-frame",
|
|
1088
|
+
children: m.length ? /* @__PURE__ */ v(A, {
|
|
1089
|
+
"aria-label": `${a} instances`,
|
|
1090
|
+
className: "la-observer-instance-table",
|
|
1091
|
+
children: [/* @__PURE__ */ _(j, { children: /* @__PURE__ */ v(N, { children: [
|
|
1092
|
+
/* @__PURE__ */ _(P, {
|
|
1093
|
+
scope: "col",
|
|
1094
|
+
children: "Instance"
|
|
1095
|
+
}),
|
|
1096
|
+
/* @__PURE__ */ _(P, {
|
|
1097
|
+
scope: "col",
|
|
1098
|
+
children: "State"
|
|
1099
|
+
}),
|
|
1100
|
+
/* @__PURE__ */ _(P, {
|
|
1101
|
+
scope: "col",
|
|
1102
|
+
children: "Connections"
|
|
1103
|
+
}),
|
|
1104
|
+
/* @__PURE__ */ _(P, {
|
|
1105
|
+
scope: "col",
|
|
1106
|
+
className: "la-observer-waiting-cell",
|
|
1107
|
+
children: "Waiting"
|
|
1108
|
+
})
|
|
1109
|
+
] }) }), /* @__PURE__ */ _(M, { children: m.map((e) => /* @__PURE__ */ v(N, {
|
|
1110
|
+
className: "la-clickable-row",
|
|
1111
|
+
onClick: () => f(e.actorId),
|
|
1112
|
+
children: [
|
|
1113
|
+
/* @__PURE__ */ _(F, {
|
|
1114
|
+
className: "la-observer-instance-id",
|
|
1115
|
+
children: /* @__PURE__ */ _(D, {
|
|
1116
|
+
variant: "ghost",
|
|
1117
|
+
type: "button",
|
|
1118
|
+
className: "la-observer-actor-button",
|
|
1119
|
+
children: /* @__PURE__ */ _("span", { children: e.actorId })
|
|
1120
|
+
})
|
|
1121
|
+
}),
|
|
1122
|
+
/* @__PURE__ */ _(F, { children: /* @__PURE__ */ v(T, {
|
|
1123
|
+
variant: "outline",
|
|
1124
|
+
className: `la-observer-status-${e.status}`,
|
|
1125
|
+
children: [/* @__PURE__ */ _("span", { className: `la-observer-dot la-observer-dot-${e.status}` }), $(e.status)]
|
|
1126
|
+
}) }),
|
|
1127
|
+
/* @__PURE__ */ _(F, { children: e.connections.length.toLocaleString() }),
|
|
1128
|
+
/* @__PURE__ */ _(F, {
|
|
1129
|
+
className: "la-observer-waiting-cell",
|
|
1130
|
+
children: /* @__PURE__ */ _(Y, {
|
|
1131
|
+
waiting: e.waiting,
|
|
1132
|
+
compact: !0
|
|
1133
|
+
})
|
|
1134
|
+
})
|
|
1135
|
+
]
|
|
1136
|
+
}, e.actorId)) })]
|
|
1137
|
+
}) : /* @__PURE__ */ _(Z, {
|
|
1138
|
+
title: "No matching instances",
|
|
1139
|
+
description: "Try another instance ID or state.",
|
|
1140
|
+
action: "Clear filters",
|
|
1141
|
+
onReset: () => {
|
|
1142
|
+
c(""), u("all");
|
|
1143
|
+
}
|
|
1144
|
+
})
|
|
1145
|
+
}),
|
|
1146
|
+
/* @__PURE__ */ _("p", {
|
|
1147
|
+
className: "la-observer-connection-note",
|
|
1148
|
+
children: "Connections are active WebSocket connections, not unique people."
|
|
1149
|
+
})
|
|
1150
|
+
] }) : /* @__PURE__ */ v("p", {
|
|
1151
|
+
className: "la-observer-instance-empty",
|
|
1152
|
+
role: "status",
|
|
1153
|
+
children: [
|
|
1154
|
+
"No ",
|
|
1155
|
+
a,
|
|
1156
|
+
" instances have been created yet."
|
|
1157
|
+
]
|
|
1158
|
+
})]
|
|
1159
|
+
}) : /* @__PURE__ */ v("section", {
|
|
1160
|
+
className: "la-observer-instance-detail",
|
|
1161
|
+
"aria-label": `${a} / ${d}`,
|
|
1162
|
+
children: [
|
|
1163
|
+
/* @__PURE__ */ _(D, {
|
|
1164
|
+
variant: "link",
|
|
1165
|
+
"aria-label": "Back to instances",
|
|
1166
|
+
onClick: () => f(void 0),
|
|
1167
|
+
children: "Back to instances"
|
|
1168
|
+
}),
|
|
1169
|
+
/* @__PURE__ */ v("div", {
|
|
1170
|
+
className: "la-observer-instance-heading",
|
|
1171
|
+
children: [/* @__PURE__ */ _("h2", {
|
|
1172
|
+
ref: y,
|
|
1173
|
+
tabIndex: -1,
|
|
1174
|
+
children: d
|
|
1175
|
+
}), h && /* @__PURE__ */ _(T, {
|
|
1176
|
+
variant: "outline",
|
|
1177
|
+
className: `la-observer-status-${h.status}`,
|
|
1178
|
+
children: $(h.status)
|
|
1179
|
+
})]
|
|
1180
|
+
}),
|
|
1181
|
+
!h && /* @__PURE__ */ _("p", {
|
|
1182
|
+
role: "status",
|
|
1183
|
+
children: "This instance is no longer in the current inventory. Its retained requests are still available below."
|
|
1184
|
+
}),
|
|
1185
|
+
h && /* @__PURE__ */ _(pe, { waiting: h.waiting }),
|
|
1186
|
+
t.watchRequests || t.query ? /* @__PURE__ */ _(K, {
|
|
1187
|
+
client: t,
|
|
1188
|
+
actor: {
|
|
1189
|
+
actorType: a,
|
|
1190
|
+
actorId: d
|
|
1191
|
+
}
|
|
1192
|
+
}, d) : /* @__PURE__ */ v("section", { children: [/* @__PURE__ */ _("h3", { children: "Requests" }), /* @__PURE__ */ _("p", { children: "Request timings are unavailable for this connection." })] }),
|
|
1193
|
+
h && /* @__PURE__ */ _(me, {
|
|
1194
|
+
id: p,
|
|
1195
|
+
actorId: h.actorId,
|
|
1196
|
+
connections: h.connections
|
|
1197
|
+
})
|
|
1198
|
+
]
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
function pe({ waiting: e }) {
|
|
1202
|
+
return /* @__PURE__ */ v("section", {
|
|
1203
|
+
className: "la-observer-waiting",
|
|
1204
|
+
"aria-label": "Waiting requests",
|
|
1205
|
+
children: [
|
|
1206
|
+
/* @__PURE__ */ v("h3", { children: ["Waiting requests", e != null && ` (${e.length})`] }),
|
|
1207
|
+
/* @__PURE__ */ _("p", { children: e == null ? "This host has not reported its waiting line." : e.length ? "Next to run first. Operations leave this line when they start." : "No requests waiting." }),
|
|
1208
|
+
!!e?.length && /* @__PURE__ */ _(Y, { waiting: e })
|
|
1209
|
+
]
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
function Y({ waiting: e, compact: t = !1 }) {
|
|
1213
|
+
if (e == null) return /* @__PURE__ */ _("span", {
|
|
1214
|
+
title: "Queue reporting is unavailable",
|
|
1215
|
+
children: "Unavailable"
|
|
1216
|
+
});
|
|
1217
|
+
if (!e.length) return /* @__PURE__ */ _("span", {
|
|
1218
|
+
className: "la-observer-queue-empty",
|
|
1219
|
+
children: "None"
|
|
1220
|
+
});
|
|
1221
|
+
let n = t ? e.slice(0, 3) : e;
|
|
1222
|
+
return /* @__PURE__ */ v("ol", {
|
|
1223
|
+
className: `la-observer-queue${t ? " la-observer-queue-compact" : ""}`,
|
|
1224
|
+
"aria-label": `${e.length} waiting requests, next to run first`,
|
|
1225
|
+
children: [n.map((e, n) => /* @__PURE__ */ _("li", { children: /* @__PURE__ */ v(T, {
|
|
1226
|
+
variant: "outline",
|
|
1227
|
+
className: "la-observer-queue-bubble",
|
|
1228
|
+
title: e.operation,
|
|
1229
|
+
children: [!t && /* @__PURE__ */ _("span", {
|
|
1230
|
+
className: "la-observer-queue-position",
|
|
1231
|
+
children: n + 1
|
|
1232
|
+
}), /* @__PURE__ */ _("span", {
|
|
1233
|
+
className: "la-observer-queue-operation",
|
|
1234
|
+
children: e.operation
|
|
1235
|
+
})]
|
|
1236
|
+
}) }, e.id)), t && e.length > n.length && /* @__PURE__ */ _("li", { children: /* @__PURE__ */ v(T, {
|
|
1237
|
+
"aria-label": `${e.length - n.length} more waiting requests`,
|
|
1238
|
+
children: ["+", e.length - n.length]
|
|
1239
|
+
}) })]
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
function me({ id: e, actorId: t, connections: n }) {
|
|
1243
|
+
return /* @__PURE__ */ v("section", {
|
|
1244
|
+
id: e,
|
|
1245
|
+
className: "la-observer-connections",
|
|
1246
|
+
"aria-labelledby": `${e}-heading`,
|
|
1247
|
+
children: [/* @__PURE__ */ _("div", {
|
|
1248
|
+
className: "la-observer-instances-heading",
|
|
1249
|
+
children: /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ v("h3", {
|
|
1250
|
+
id: `${e}-heading`,
|
|
1251
|
+
children: [
|
|
1252
|
+
t,
|
|
1253
|
+
" WebSockets ",
|
|
1254
|
+
/* @__PURE__ */ _(T, {
|
|
1255
|
+
"aria-hidden": "true",
|
|
1256
|
+
children: n.length.toLocaleString()
|
|
1257
|
+
})
|
|
1258
|
+
]
|
|
1259
|
+
}), /* @__PURE__ */ _("p", { children: `${n.length.toLocaleString()} active ${n.length === 1 ? "connection" : "connections"}` })] })
|
|
1260
|
+
}), n.length ? /* @__PURE__ */ _("div", {
|
|
1261
|
+
className: "la-observer-table-frame",
|
|
1262
|
+
children: /* @__PURE__ */ v(A, {
|
|
1263
|
+
"aria-label": `${t} WebSocket connections`,
|
|
1264
|
+
className: "la-observer-connection-table",
|
|
1265
|
+
children: [/* @__PURE__ */ _(j, { children: /* @__PURE__ */ v(N, { children: [/* @__PURE__ */ _(P, {
|
|
1266
|
+
scope: "col",
|
|
1267
|
+
children: "Socket"
|
|
1268
|
+
}), /* @__PURE__ */ _(P, {
|
|
1269
|
+
scope: "col",
|
|
1270
|
+
children: "Metadata"
|
|
1271
|
+
})] }) }), /* @__PURE__ */ _(M, { children: n.map((e) => /* @__PURE__ */ v(N, { children: [/* @__PURE__ */ _(F, {
|
|
1272
|
+
className: "la-observer-socket-id",
|
|
1273
|
+
children: e.id
|
|
1274
|
+
}), /* @__PURE__ */ _(F, { children: /* @__PURE__ */ _("pre", { children: JSON.stringify(e.metadata, null, 2) }) })] }, e.id)) })]
|
|
1275
|
+
})
|
|
1276
|
+
}) : /* @__PURE__ */ v("div", {
|
|
1277
|
+
className: "la-observer-no-connections",
|
|
1278
|
+
role: "status",
|
|
1279
|
+
children: [/* @__PURE__ */ _(d, { "aria-hidden": "true" }), /* @__PURE__ */ _("p", { children: "No active WebSocket connections." })]
|
|
1280
|
+
})]
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
function X({ label: e, placeholder: t, value: n, onChange: r }) {
|
|
1284
|
+
return /* @__PURE__ */ v("div", {
|
|
1285
|
+
className: "la-observer-search",
|
|
1286
|
+
children: [/* @__PURE__ */ _(u, { "aria-hidden": "true" }), /* @__PURE__ */ _(O, {
|
|
1287
|
+
type: "search",
|
|
1288
|
+
"aria-label": e,
|
|
1289
|
+
placeholder: t,
|
|
1290
|
+
value: n,
|
|
1291
|
+
onInput: (e) => r(e.currentTarget.value)
|
|
1292
|
+
})]
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
function Z({ title: e, description: t, action: n, onReset: r }) {
|
|
1296
|
+
return /* @__PURE__ */ v("div", {
|
|
1297
|
+
className: "la-observer-empty",
|
|
1298
|
+
children: [
|
|
1299
|
+
/* @__PURE__ */ _(u, { "aria-hidden": "true" }),
|
|
1300
|
+
/* @__PURE__ */ _("h3", { children: e }),
|
|
1301
|
+
/* @__PURE__ */ _("p", { children: t }),
|
|
1302
|
+
n && /* @__PURE__ */ _(D, {
|
|
1303
|
+
type: "button",
|
|
1304
|
+
variant: "outline",
|
|
1305
|
+
onClick: r,
|
|
1306
|
+
children: n
|
|
1307
|
+
})
|
|
1308
|
+
]
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
function Q(e, t) {
|
|
1312
|
+
return e.toLocaleLowerCase().includes(t.trim().toLocaleLowerCase());
|
|
1313
|
+
}
|
|
1314
|
+
function $(e) {
|
|
1315
|
+
return e[0].toUpperCase() + e.slice(1);
|
|
1316
|
+
}
|
|
1317
|
+
//#endregion
|
|
1318
|
+
export { le as ActorObserver, L as HttpObserverClient, K as RequestObserver };
|