@concavejs/devtools 0.0.1-alpha.5 → 0.0.1-alpha.6

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/dist/index.js CHANGED
@@ -1,78 +1,130 @@
1
- var m = Object.defineProperty;
2
- var v = (c, e, t) => e in c ? m(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
- var d = (c, e, t) => v(c, typeof e != "symbol" ? e + "" : e, t);
4
- import { b as w, D as P, E, L as S, P as A, a as L, S as M, g as D, i as $ } from "./client-D6NyDOCN.js";
5
- import { concaveDevTools as R } from "./vite-plugin.js";
6
- function T(c) {
7
- const e = c.split(".");
8
- if (e.length < 2) return null;
1
+ import { b as M, D as k, E as A, L as D, P as $, a as C, S as R, g as W, i as O } from "./client-B2IPTPCG.js";
2
+ import { concaveDevTools as N } from "./vite-plugin.js";
3
+ function P(c) {
4
+ const t = c.split(".");
5
+ if (t.length < 2) return null;
9
6
  try {
10
- const t = e[1].replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), s = JSON.parse(atob(n)), o = ["iss", "sub", "aud", "exp", "iat", "nbf"], i = {};
11
- for (const a of o) {
12
- const u = s[a];
13
- u !== void 0 && (i[a] = u);
7
+ const e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "=".repeat((4 - e.length % 4) % 4), o = JSON.parse(atob(n)), s = ["iss", "sub", "aud", "exp", "iat", "nbf"], i = {};
8
+ for (const a of s) {
9
+ const d = o[a];
10
+ d !== void 0 && (i[a] = d);
14
11
  }
15
12
  return typeof i.exp == "number" && (i.expIso = new Date(i.exp * 1e3).toISOString()), typeof i.iat == "number" && (i.iatIso = new Date(i.iat * 1e3).toISOString()), Object.keys(i).length > 0 ? i : null;
16
13
  } catch {
17
14
  return null;
18
15
  }
19
16
  }
20
- class I {
21
- constructor(e) {
22
- d(this, "eventStore");
23
- d(this, "originalWebSocket");
24
- d(this, "pendingQueries", /* @__PURE__ */ new Map());
25
- d(this, "pendingMutations", /* @__PURE__ */ new Map());
26
- d(this, "pendingActions", /* @__PURE__ */ new Map());
27
- d(this, "pendingAuthTokenType", null);
28
- /** Tracks the most recent mutation event ID for causality linking */
29
- d(this, "lastMutationEventId", null);
30
- d(this, "lastMutationTimestamp", 0);
31
- this.eventStore = e, this.originalWebSocket = window.WebSocket;
17
+ const v = Symbol.for("__concaveDevToolsInternalWsListener"), m = Symbol.for("__concaveDevToolsWsDelayMs");
18
+ function q() {
19
+ const c = window.__concaveDevToolsLatencyConfig;
20
+ if (!c) return 0;
21
+ const t = Number(c.latencyMs) || 0, e = Number(c.jitterMs) || 0;
22
+ if (t <= 0 && e <= 0) return 0;
23
+ const n = e > 0 ? (Math.random() * 2 - 1) * e : 0;
24
+ return Math.max(0, t + n);
25
+ }
26
+ function T(c) {
27
+ const t = c[m];
28
+ if (typeof t == "number" && Number.isFinite(t) && t >= 0)
29
+ return t;
30
+ const e = q();
31
+ try {
32
+ Object.defineProperty(c, m, {
33
+ value: e,
34
+ configurable: !0
35
+ });
36
+ } catch {
37
+ c[m] = e;
38
+ }
39
+ return e;
40
+ }
41
+ function E(c, t, e) {
42
+ if (c[v]) {
43
+ c.call(t, e);
44
+ return;
45
+ }
46
+ const n = T(e);
47
+ if (n <= 0) {
48
+ c.call(t, e);
49
+ return;
50
+ }
51
+ setTimeout(() => {
52
+ c.call(t, e);
53
+ }, n);
54
+ }
55
+ class S {
56
+ eventStore;
57
+ originalWebSocket;
58
+ pendingQueries = /* @__PURE__ */ new Map();
59
+ pendingMutations = /* @__PURE__ */ new Map();
60
+ pendingActions = /* @__PURE__ */ new Map();
61
+ pendingAuthTokenType = null;
62
+ /** Tracks the most recent mutation event ID for causality linking */
63
+ lastMutationEventId = null;
64
+ lastMutationTimestamp = 0;
65
+ constructor(t) {
66
+ this.eventStore = t, this.originalWebSocket = window.WebSocket;
32
67
  }
33
68
  /**
34
69
  * Install the WebSocket interceptor
35
70
  */
36
71
  install() {
37
- const e = this, t = this.originalWebSocket;
38
- class n extends t {
39
- constructor(o, i) {
40
- super(o, i);
41
- const a = this.addEventListener.bind(this);
42
- this.addEventListener = (r, l, h) => {
43
- r === "message" && typeof l == "function" ? a("message", (p) => {
44
- try {
45
- e.handleServerMessage(p.data);
46
- } catch (f) {
47
- console.warn("[DevTools] Error parsing server message:", f);
48
- }
49
- l(p);
50
- }, h) : a(r, l, h);
51
- };
52
- let u = null;
53
- Object.defineProperty(this, "onmessage", {
54
- get: () => u,
55
- set: (r) => {
56
- u = r, r && a("message", (h) => {
72
+ const t = this;
73
+ window.__concaveDevToolsLatencyConfig || (window.__concaveDevToolsLatencyConfig = { latencyMs: 0, jitterMs: 0 });
74
+ const e = this.originalWebSocket;
75
+ class n extends e {
76
+ constructor(s, i) {
77
+ super(s, i);
78
+ const a = this.addEventListener.bind(this), d = this.removeEventListener.bind(this), p = /* @__PURE__ */ new WeakMap();
79
+ this.addEventListener = (u, r, h) => {
80
+ if (u === "message" && typeof r == "function") {
81
+ let l = p.get(r);
82
+ l || (l = (y) => {
57
83
  try {
58
- e.handleServerMessage(h.data);
59
- } catch (g) {
60
- console.warn("[DevTools] Error parsing server message:", g);
84
+ const f = T(y);
85
+ t.handleServerMessage(y.data, f);
86
+ } catch (f) {
87
+ console.warn("[DevTools] Error parsing server message:", f);
61
88
  }
62
- r.call(this, h);
63
- });
89
+ E(r, this, y);
90
+ }, l[v] = !0, p.set(r, l)), a("message", l, h);
91
+ } else
92
+ a(u, r, h);
93
+ }, this.removeEventListener = (u, r, h) => {
94
+ if (u === "message" && typeof r == "function") {
95
+ const l = p.get(r);
96
+ d("message", l ?? r, h);
97
+ } else
98
+ d(u, r, h);
99
+ };
100
+ let b = null, g = null;
101
+ Object.defineProperty(this, "onmessage", {
102
+ get: () => b,
103
+ set: (u) => {
104
+ if (g && (d("message", g), g = null), b = u, u) {
105
+ const r = (h) => {
106
+ try {
107
+ const l = T(h);
108
+ t.handleServerMessage(h.data, l);
109
+ } catch (l) {
110
+ console.warn("[DevTools] Error parsing server message:", l);
111
+ }
112
+ E(u, this, h);
113
+ };
114
+ r[v] = !0, g = r, a("message", r);
115
+ }
64
116
  },
65
117
  configurable: !0,
66
118
  enumerable: !0
67
119
  });
68
- const y = this.send.bind(this);
69
- this.send = (r) => {
120
+ const I = this.send.bind(this);
121
+ this.send = (u) => {
70
122
  try {
71
- typeof r == "string" && e.handleClientMessage(r);
72
- } catch (l) {
73
- console.warn("[DevTools] Error parsing client message:", l);
123
+ typeof u == "string" && t.handleClientMessage(u);
124
+ } catch (r) {
125
+ console.warn("[DevTools] Error parsing client message:", r);
74
126
  }
75
- y(r);
127
+ I(u);
76
128
  };
77
129
  }
78
130
  }
@@ -87,71 +139,71 @@ class I {
87
139
  /**
88
140
  * Handle client → server messages
89
141
  */
90
- handleClientMessage(e) {
142
+ handleClientMessage(t) {
91
143
  try {
92
- const t = JSON.parse(e);
93
- switch (console.log("[DevTools] Client message:", t.type, t), t.type) {
144
+ const e = JSON.parse(t);
145
+ switch (console.log("[DevTools] Client message:", e.type, e), e.type) {
94
146
  case "ModifyQuerySet":
95
- this.handleModifyQuerySet(t.modifications);
147
+ this.handleModifyQuerySet(e.modifications);
96
148
  break;
97
149
  case "Mutation":
98
- this.handleMutationRequest(t);
150
+ this.handleMutationRequest(e);
99
151
  break;
100
152
  case "Action":
101
- this.handleActionRequest(t);
153
+ this.handleActionRequest(e);
102
154
  break;
103
155
  case "Connect":
104
- this.handleConnectMessage(t);
156
+ this.handleConnectMessage(e);
105
157
  break;
106
158
  case "Authenticate":
107
- this.handleAuthenticateMessage(t);
159
+ this.handleAuthenticateMessage(e);
108
160
  break;
109
161
  }
110
- } catch (t) {
111
- console.warn("[DevTools] Failed to parse client message:", t);
162
+ } catch (e) {
163
+ console.warn("[DevTools] Failed to parse client message:", e);
112
164
  }
113
165
  }
114
166
  /**
115
167
  * Handle server → client messages
116
168
  */
117
- handleServerMessage(e) {
169
+ handleServerMessage(t, e = 0) {
118
170
  try {
119
- const t = JSON.parse(e);
120
- switch (console.log("[DevTools] Server message:", t.type, t), t.type) {
171
+ const n = JSON.parse(t);
172
+ switch (console.log("[DevTools] Server message:", n.type, n), n.type) {
121
173
  case "Transition":
122
- this.handleTransition(t);
174
+ this.handleTransition(n, e);
123
175
  break;
124
176
  case "MutationResponse":
125
- this.handleMutationResponse(t);
177
+ this.handleMutationResponse(n, e);
126
178
  break;
127
179
  case "ActionResponse":
128
- this.handleActionResponse(t);
180
+ this.handleActionResponse(n, e);
129
181
  break;
130
182
  case "AuthError":
131
- this.handleAuthErrorResponse(t);
183
+ this.handleAuthErrorResponse(n);
132
184
  break;
133
185
  }
134
- } catch (t) {
135
- console.warn("[DevTools] Failed to parse server message:", t);
186
+ } catch (n) {
187
+ console.warn("[DevTools] Failed to parse server message:", n);
136
188
  }
137
189
  }
138
190
  /**
139
191
  * Handle query set modifications (subscriptions)
140
192
  */
141
- handleModifyQuerySet(e) {
142
- const t = Date.now();
143
- for (const n of e)
193
+ handleModifyQuerySet(t) {
194
+ const e = Date.now();
195
+ for (const n of t)
144
196
  if (n.type === "Add") {
145
197
  this.pendingQueries.set(n.queryId, {
146
198
  queryId: n.queryId,
147
199
  udfPath: n.udfPath,
148
200
  args: n.args,
149
201
  componentPath: n.componentPath,
150
- startTime: t
202
+ startTime: e
151
203
  });
152
- const s = {
153
- id: `sub-${n.queryId}-${t}`,
154
- timestamp: t,
204
+ const o = {
205
+ id: `sub-${n.queryId}-${e}`,
206
+ timestamp: e,
155
207
  type: "subscription",
156
208
  queryId: n.queryId,
157
209
  udfPath: n.udfPath,
@@ -159,222 +211,263 @@ class I {
159
211
  componentPath: n.componentPath,
160
212
  status: "added"
161
213
  };
214
+ this.eventStore.addEvent(o);
215
+ const s = {
216
+ id: `query-pending-${n.queryId}-${e}`,
217
+ timestamp: e,
218
+ type: "query",
219
+ queryId: n.queryId,
220
+ udfPath: n.udfPath,
221
+ args: n.args,
222
+ componentPath: n.componentPath,
223
+ status: "pending"
224
+ };
162
225
  this.eventStore.addEvent(s);
163
226
  } else if (n.type === "Remove") {
164
- const s = this.pendingQueries.get(n.queryId);
165
- if (this.pendingQueries.delete(n.queryId), s) {
166
- const o = {
167
- id: `sub-${n.queryId}-${t}`,
168
- timestamp: t,
227
+ const o = this.pendingQueries.get(n.queryId);
228
+ if (this.pendingQueries.delete(n.queryId), o) {
229
+ const s = {
230
+ id: `sub-${n.queryId}-${e}`,
231
+ timestamp: e,
169
232
  type: "subscription",
170
233
  queryId: n.queryId,
171
- udfPath: s.udfPath,
172
- args: s.args,
173
- componentPath: s.componentPath,
234
+ udfPath: o.udfPath,
235
+ args: o.args,
236
+ componentPath: o.componentPath,
174
237
  status: "removed"
175
238
  };
176
- this.eventStore.addEvent(o);
239
+ this.eventStore.addEvent(s);
177
240
  }
178
241
  }
179
242
  }
180
243
  /**
181
244
  * Handle mutation requests
182
245
  */
183
- handleMutationRequest(e) {
184
- const t = Date.now();
185
- this.pendingMutations.set(e.requestId, {
186
- requestId: e.requestId,
187
- udfPath: e.udfPath,
188
- args: e.args,
189
- componentPath: e.componentPath,
190
- startTime: t
246
+ handleMutationRequest(t) {
247
+ const e = Date.now();
248
+ this.pendingMutations.set(t.requestId, {
249
+ requestId: t.requestId,
250
+ udfPath: t.udfPath,
251
+ args: t.args,
252
+ componentPath: t.componentPath,
253
+ startTime: e
191
254
  });
255
+ const n = {
256
+ id: `mutation-pending-${t.requestId}-${e}`,
257
+ timestamp: e,
258
+ type: "mutation",
259
+ requestId: t.requestId,
260
+ udfPath: t.udfPath,
261
+ args: t.args,
262
+ componentPath: t.componentPath,
263
+ status: "pending"
264
+ };
265
+ this.eventStore.addEvent(n);
192
266
  }
193
267
  /**
194
268
  * Handle action requests
195
269
  */
196
- handleActionRequest(e) {
197
- const t = Date.now();
198
- this.pendingActions.set(e.requestId, {
199
- requestId: e.requestId,
200
- udfPath: e.udfPath,
201
- args: e.args,
202
- componentPath: e.componentPath,
203
- startTime: t
270
+ handleActionRequest(t) {
271
+ const e = Date.now();
272
+ this.pendingActions.set(t.requestId, {
273
+ requestId: t.requestId,
274
+ udfPath: t.udfPath,
275
+ args: t.args,
276
+ componentPath: t.componentPath,
277
+ startTime: e
204
278
  });
279
+ const n = {
280
+ id: `action-pending-${t.requestId}-${e}`,
281
+ timestamp: e,
282
+ type: "action",
283
+ requestId: t.requestId,
284
+ udfPath: t.udfPath,
285
+ args: t.args,
286
+ componentPath: t.componentPath,
287
+ status: "pending"
288
+ };
289
+ this.eventStore.addEvent(n);
205
290
  }
206
- handleConnectMessage(e) {
207
- const t = {};
208
- typeof e.connectionCount == "number" && (t.connectionCount = e.connectionCount), typeof e.lastCloseReason == "string" && (t.lastCloseReason = e.lastCloseReason), typeof e.clientTs == "number" && (t.clientTs = e.clientTs), typeof e.sessionId == "string" && (t.sessionId = e.sessionId), this.emitAuthEvent({
291
+ handleConnectMessage(t) {
292
+ const e = {};
293
+ typeof t.connectionCount == "number" && (e.connectionCount = t.connectionCount), typeof t.lastCloseReason == "string" && (e.lastCloseReason = t.lastCloseReason), typeof t.clientTs == "number" && (e.clientTs = t.clientTs), typeof t.sessionId == "string" && (e.sessionId = t.sessionId), this.emitAuthEvent({
209
294
  direction: "client",
210
295
  messageType: "Connect",
211
296
  status: "success",
212
- details: t
297
+ details: e
213
298
  });
214
299
  }
215
- handleAuthenticateMessage(e) {
216
- const t = {};
217
- if (typeof e.baseVersion == "number" && (t.baseVersion = e.baseVersion), typeof e.tokenType == "string" && (t.tokenType = e.tokenType), typeof e.value == "string" && e.value.length > 0) {
218
- const n = e.value;
219
- t.tokenLength = n.length, t.tokenPreview = n.length > 24 ? `${n.slice(0, 12)}…${n.slice(-10)}` : n;
220
- const s = T(n);
221
- s && (t.jwtClaims = s);
300
+ handleAuthenticateMessage(t) {
301
+ const e = {};
302
+ if (typeof t.baseVersion == "number" && (e.baseVersion = t.baseVersion), typeof t.tokenType == "string" && (e.tokenType = t.tokenType), typeof t.value == "string" && t.value.length > 0) {
303
+ const n = t.value;
304
+ e.tokenLength = n.length, e.tokenPreview = n.length > 24 ? `${n.slice(0, 12)}…${n.slice(-10)}` : n;
305
+ const o = P(n);
306
+ o && (e.jwtClaims = o);
222
307
  }
223
- this.pendingAuthTokenType = e.tokenType ?? "Unknown", this.emitAuthEvent({
308
+ this.pendingAuthTokenType = t.tokenType ?? "Unknown", this.emitAuthEvent({
224
309
  direction: "client",
225
310
  messageType: "Authenticate",
226
311
  status: "success",
227
- tokenType: e.tokenType,
228
- details: t
312
+ tokenType: t.tokenType,
313
+ details: e
229
314
  });
230
315
  }
231
316
  /**
232
317
  * Handle state transitions (query updates)
233
318
  */
234
- handleTransition(e) {
235
- const t = Date.now();
319
+ handleTransition(t, e = 0) {
320
+ const n = Date.now();
236
321
  this.pendingAuthTokenType && (this.emitAuthEvent({
237
322
  direction: "server",
238
323
  messageType: "Authenticated",
239
324
  status: "success",
240
325
  tokenType: this.pendingAuthTokenType,
241
- details: { modificationCount: e.modifications.length }
326
+ details: { modificationCount: t.modifications.length }
242
327
  }), this.pendingAuthTokenType = null);
243
- for (const n of e.modifications)
244
- if (n.type === "QueryUpdated") {
245
- const s = this.pendingQueries.get(n.queryId);
328
+ for (const o of t.modifications)
329
+ if (o.type === "QueryUpdated") {
330
+ const s = this.pendingQueries.get(o.queryId);
246
331
  if (!s) continue;
247
- const o = t - s.startTime, i = this.lastMutationEventId && t - this.lastMutationTimestamp < 2e3 ? this.lastMutationEventId : void 0, a = {
248
- id: `query-${n.queryId}-${t}`,
249
- timestamp: t,
332
+ const i = n - s.startTime, a = this.resolveOperationTimings(i, e), d = this.lastMutationEventId && n - this.lastMutationTimestamp < 2e3 ? this.lastMutationEventId : void 0, p = {
333
+ id: `query-${o.queryId}-${n}`,
334
+ timestamp: n,
250
335
  type: "query",
251
- queryId: n.queryId,
336
+ queryId: o.queryId,
252
337
  udfPath: s.udfPath,
253
338
  args: s.args,
254
339
  componentPath: s.componentPath,
255
340
  status: "success",
256
- result: n.value,
257
- logLines: n.logLines,
258
- duration: o,
259
- triggeredBy: i
341
+ result: o.value,
342
+ logLines: o.logLines,
343
+ ...a,
344
+ triggeredBy: d
260
345
  };
261
- this.eventStore.addEvent(a), Array.isArray(n.logLines) && n.logLines.length > 0 && this.emitLogEvents(n.logLines, a.id);
262
- } else if (n.type === "QueryFailed") {
263
- const s = this.pendingQueries.get(n.queryId);
346
+ this.eventStore.addEvent(p), Array.isArray(o.logLines) && o.logLines.length > 0 && this.emitLogEvents(o.logLines, p.id);
347
+ } else if (o.type === "QueryFailed") {
348
+ const s = this.pendingQueries.get(o.queryId);
264
349
  if (!s) continue;
265
- const o = t - s.startTime, i = {
266
- id: `query-${n.queryId}-${t}`,
267
- timestamp: t,
350
+ const i = n - s.startTime, a = this.resolveOperationTimings(i, e), d = {
351
+ id: `query-${o.queryId}-${n}`,
352
+ timestamp: n,
268
353
  type: "query",
269
- queryId: n.queryId,
354
+ queryId: o.queryId,
270
355
  udfPath: s.udfPath,
271
356
  args: s.args,
272
357
  componentPath: s.componentPath,
273
358
  status: "error",
274
- error: n.errorMessage,
275
- logLines: n.logLines,
276
- duration: o
359
+ error: o.errorMessage,
360
+ logLines: o.logLines,
361
+ ...a
277
362
  };
278
- this.eventStore.addEvent(i), Array.isArray(n.logLines) && n.logLines.length > 0 && this.emitLogEvents(n.logLines, i.id);
363
+ this.eventStore.addEvent(d), Array.isArray(o.logLines) && o.logLines.length > 0 && this.emitLogEvents(o.logLines, d.id);
279
364
  }
280
365
  }
281
366
  /**
282
367
  * Handle mutation responses
283
368
  */
284
- handleMutationResponse(e) {
285
- const t = this.pendingMutations.get(e.requestId);
286
- if (!t) return;
287
- const n = Date.now(), s = n - t.startTime, o = {
288
- id: `mutation-${e.requestId}-${n}`,
289
- timestamp: n,
369
+ handleMutationResponse(t, e = 0) {
370
+ const n = this.pendingMutations.get(t.requestId);
371
+ if (!n) return;
372
+ const o = Date.now(), s = o - n.startTime, i = this.resolveOperationTimings(s, e), a = {
373
+ id: `mutation-${t.requestId}-${o}`,
374
+ timestamp: o,
290
375
  type: "mutation",
291
- requestId: e.requestId,
292
- udfPath: t.udfPath,
293
- args: t.args,
294
- componentPath: t.componentPath,
295
- status: e.success ? "success" : "error",
296
- result: e.success ? e.result : void 0,
297
- error: e.success ? void 0 : e.result,
298
- logLines: e.logLines,
299
- duration: s
376
+ requestId: t.requestId,
377
+ udfPath: n.udfPath,
378
+ args: n.args,
379
+ componentPath: n.componentPath,
380
+ status: t.success ? "success" : "error",
381
+ result: t.success ? t.result : void 0,
382
+ error: t.success ? void 0 : t.result,
383
+ logLines: t.logLines,
384
+ ...i
300
385
  };
301
- this.eventStore.addEvent(o), this.lastMutationEventId = o.id, this.lastMutationTimestamp = n, e.logLines && e.logLines.length > 0 && this.emitLogEvents(e.logLines, o.id), this.pendingMutations.delete(e.requestId);
386
+ this.eventStore.addEvent(a), this.lastMutationEventId = a.id, this.lastMutationTimestamp = o, t.logLines && t.logLines.length > 0 && this.emitLogEvents(t.logLines, a.id), this.pendingMutations.delete(t.requestId);
302
387
  }
303
388
  /**
304
389
  * Handle action responses
305
390
  */
306
- handleActionResponse(e) {
307
- const t = this.pendingActions.get(e.requestId);
308
- if (!t) return;
309
- const n = Date.now(), s = n - t.startTime, o = {
310
- id: `action-${e.requestId}-${n}`,
311
- timestamp: n,
391
+ handleActionResponse(t, e = 0) {
392
+ const n = this.pendingActions.get(t.requestId);
393
+ if (!n) return;
394
+ const o = Date.now(), s = o - n.startTime, i = this.resolveOperationTimings(s, e), a = {
395
+ id: `action-${t.requestId}-${o}`,
396
+ timestamp: o,
312
397
  type: "action",
313
- requestId: e.requestId,
314
- udfPath: t.udfPath,
315
- args: t.args,
316
- componentPath: t.componentPath,
317
- status: e.success ? "success" : "error",
318
- result: e.success ? e.result : void 0,
319
- error: e.success ? void 0 : e.result,
320
- logLines: e.logLines,
321
- duration: s
398
+ requestId: t.requestId,
399
+ udfPath: n.udfPath,
400
+ args: n.args,
401
+ componentPath: n.componentPath,
402
+ status: t.success ? "success" : "error",
403
+ result: t.success ? t.result : void 0,
404
+ error: t.success ? void 0 : t.result,
405
+ logLines: t.logLines,
406
+ ...i
322
407
  };
323
- this.eventStore.addEvent(o), e.logLines && e.logLines.length > 0 && this.emitLogEvents(e.logLines, o.id), this.pendingActions.delete(e.requestId);
408
+ this.eventStore.addEvent(a), t.logLines && t.logLines.length > 0 && this.emitLogEvents(t.logLines, a.id), this.pendingActions.delete(t.requestId);
324
409
  }
325
- handleAuthErrorResponse(e) {
326
- const t = {};
327
- typeof e.baseVersion == "number" && (t.baseVersion = e.baseVersion), typeof e.authUpdateAttempted == "boolean" && (t.authUpdateAttempted = e.authUpdateAttempted), this.emitAuthEvent({
410
+ handleAuthErrorResponse(t) {
411
+ const e = {};
412
+ typeof t.baseVersion == "number" && (e.baseVersion = t.baseVersion), typeof t.authUpdateAttempted == "boolean" && (e.authUpdateAttempted = t.authUpdateAttempted), this.emitAuthEvent({
328
413
  direction: "server",
329
414
  messageType: "AuthError",
330
415
  status: "error",
331
416
  tokenType: this.pendingAuthTokenType ?? void 0,
332
- error: e.error ?? "Authentication failed",
333
- details: t
417
+ error: t.error ?? "Authentication failed",
418
+ details: e
334
419
  }), this.pendingAuthTokenType = null;
335
420
  }
336
- emitAuthEvent(e) {
337
- const t = Date.now(), n = {
338
- id: `auth-${e.direction}-${e.messageType}-${t}-${Math.random().toString(36).slice(2, 8)}`,
339
- timestamp: t,
421
+ resolveOperationTimings(t, e) {
422
+ const n = Number.isFinite(t) && t >= 0 ? t : 0, o = Number.isFinite(e) && e > 0 ? e : 0;
423
+ return {
424
+ duration: n,
425
+ simulatedDelayMs: o,
426
+ endToEndDurationMs: n + o
427
+ };
428
+ }
429
+ emitAuthEvent(t) {
430
+ const e = Date.now(), n = {
431
+ id: `auth-${t.direction}-${t.messageType}-${e}-${Math.random().toString(36).slice(2, 8)}`,
432
+ timestamp: e,
340
433
  type: "auth",
341
- direction: e.direction,
342
- messageType: e.messageType,
343
- status: e.status,
344
- tokenType: e.tokenType,
345
- error: e.error,
346
- details: e.details
434
+ direction: t.direction,
435
+ messageType: t.messageType,
436
+ status: t.status,
437
+ tokenType: t.tokenType,
438
+ error: t.error,
439
+ details: t.details
347
440
  };
348
441
  this.eventStore.addEvent(n);
349
442
  }
350
443
  /**
351
444
  * Extract and emit log events from logLines
352
445
  */
353
- emitLogEvents(e, t) {
446
+ emitLogEvents(t, e) {
354
447
  const n = Date.now();
355
- for (const s of e) {
356
- const o = s.match(/^\[(log|info|warn|error)\]\s+(.+)$/i), i = o ? o[1].toLowerCase() : "log", a = o ? o[2] : s, u = {
448
+ for (const o of t) {
449
+ const s = o.match(/^\[(log|info|warn|error)\]\s+(.+)$/i), i = s ? s[1].toLowerCase() : "log", a = s ? s[2] : o, d = {
357
450
  id: `log-${n}-${Math.random()}`,
358
451
  timestamp: n,
359
452
  type: "log",
360
453
  level: i,
361
454
  message: a,
362
- relatedEventId: t
455
+ relatedEventId: e
363
456
  };
364
- this.eventStore.addEvent(u);
457
+ this.eventStore.addEvent(d);
365
458
  }
366
459
  }
367
460
  }
368
461
  export {
369
- w as DataInspector,
370
- P as DevToolbar,
371
- E as EventStore,
372
- S as LogsPanel,
373
- A as PerformancePanel,
374
- L as SettingsPanel,
375
- M as SubscriptionsPanel,
376
- I as WebSocketInterceptor,
377
- R as concaveDevTools,
378
- D as getGlobalEventStore,
379
- $ as initDevTools
462
+ M as DataInspector,
463
+ k as DevToolbar,
464
+ A as EventStore,
465
+ D as LogsPanel,
466
+ $ as PerformancePanel,
467
+ C as SettingsPanel,
468
+ R as SubscriptionsPanel,
469
+ S as WebSocketInterceptor,
470
+ N as concaveDevTools,
471
+ W as getGlobalEventStore,
472
+ O as initDevTools
380
473
  };