@concavejs/devtools 0.0.1-alpha.10 → 0.0.1-alpha.12

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