@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/{client-CRYWrjNv.js → client-Bnix0wGg.js} +195 -192
- package/dist/client.js +1 -1
- package/dist/index.js +266 -268
- package/dist/interceptor/websocket-interceptor.d.ts +6 -4
- package/dist/store/event-store.d.ts +1 -0
- package/dist/vite-plugin.js +143 -98
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { b as
|
|
2
|
-
import { concaveDevTools as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
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 =
|
|
8
|
-
for (const
|
|
9
|
-
const
|
|
10
|
-
|
|
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
|
|
18
|
+
function S() {
|
|
19
19
|
const c = window.__concaveDevToolsLatencyConfig;
|
|
20
20
|
if (!c) return 0;
|
|
21
|
-
const
|
|
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 =
|
|
25
|
-
let
|
|
26
|
-
if (n <= 0 &&
|
|
27
|
-
n > 0 &&
|
|
28
|
-
const o =
|
|
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
|
|
33
|
-
if (typeof
|
|
34
|
-
return
|
|
35
|
-
const n =
|
|
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
|
|
46
|
+
function I(c, e, n) {
|
|
47
47
|
if (c[v]) {
|
|
48
|
-
c.call(
|
|
48
|
+
c.call(e, n);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
let
|
|
51
|
+
let t = 0;
|
|
52
52
|
try {
|
|
53
|
-
|
|
53
|
+
t = T(n);
|
|
54
54
|
} catch {
|
|
55
|
-
|
|
55
|
+
t = 0;
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
58
|
-
c.call(
|
|
57
|
+
if (t <= 0) {
|
|
58
|
+
c.call(e, n);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
setTimeout(() => {
|
|
62
|
-
c.call(
|
|
63
|
-
},
|
|
62
|
+
c.call(e, n);
|
|
63
|
+
}, t);
|
|
64
64
|
}
|
|
65
|
-
class
|
|
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(
|
|
76
|
-
this.eventStore =
|
|
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
|
|
84
|
+
const e = this;
|
|
83
85
|
window.__concaveDevToolsLatencyConfig || (window.__concaveDevToolsLatencyConfig = { latencyMs: 0, jitterMs: 0 });
|
|
84
86
|
const n = this.originalWebSocket;
|
|
85
|
-
class
|
|
87
|
+
class t extends n {
|
|
86
88
|
constructor(s, i) {
|
|
87
89
|
super(s, i);
|
|
88
|
-
const
|
|
89
|
-
this.addEventListener = (
|
|
90
|
-
if (
|
|
91
|
-
let
|
|
92
|
-
|
|
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
|
-
|
|
97
|
+
e.handleServerMessage(y.data, f);
|
|
96
98
|
} catch (f) {
|
|
97
99
|
console.warn("[DevTools] Error parsing server message:", f);
|
|
98
100
|
}
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
+
I(a, this, y);
|
|
102
|
+
}, u[v] = !0, p.set(a, u)), r("message", u, l);
|
|
101
103
|
} else
|
|
102
|
-
|
|
103
|
-
}, this.removeEventListener = (
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
|
|
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
|
|
110
|
+
h(d, a, l);
|
|
109
111
|
};
|
|
110
|
-
let
|
|
112
|
+
let E = null, g = null;
|
|
111
113
|
Object.defineProperty(this, "onmessage", {
|
|
112
|
-
get: () =>
|
|
113
|
-
set: (
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
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
|
|
118
|
-
|
|
119
|
-
} catch (
|
|
120
|
-
console.warn("[DevTools] Error parsing server message:",
|
|
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
|
-
|
|
124
|
+
I(d, this, l);
|
|
123
125
|
};
|
|
124
|
-
|
|
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
|
|
131
|
-
this.send = (
|
|
132
|
+
const b = this.send.bind(this);
|
|
133
|
+
this.send = (d) => {
|
|
132
134
|
try {
|
|
133
|
-
typeof
|
|
134
|
-
} catch (
|
|
135
|
-
console.warn("[DevTools] Error parsing client message:",
|
|
135
|
+
typeof d == "string" && e.handleClientMessage(d);
|
|
136
|
+
} catch (a) {
|
|
137
|
+
console.warn("[DevTools] Error parsing client message:", a);
|
|
136
138
|
}
|
|
137
|
-
|
|
139
|
+
b(d);
|
|
138
140
|
};
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
|
-
window.WebSocket =
|
|
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(
|
|
154
|
+
handleClientMessage(e) {
|
|
153
155
|
try {
|
|
154
|
-
const n = JSON.parse(
|
|
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(
|
|
181
|
+
handleServerMessage(e, n = 0) {
|
|
180
182
|
try {
|
|
181
|
-
const
|
|
182
|
-
switch (console.log("[DevTools] Server message:",
|
|
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(
|
|
186
|
+
this.handleTransition(t, n);
|
|
185
187
|
break;
|
|
186
188
|
case "MutationResponse":
|
|
187
|
-
this.handleMutationResponse(
|
|
189
|
+
this.handleMutationResponse(t, n);
|
|
188
190
|
break;
|
|
189
191
|
case "ActionResponse":
|
|
190
|
-
this.handleActionResponse(
|
|
192
|
+
this.handleActionResponse(t, n);
|
|
191
193
|
break;
|
|
192
194
|
case "AuthError":
|
|
193
|
-
this.handleAuthErrorResponse(
|
|
195
|
+
this.handleAuthErrorResponse(t);
|
|
194
196
|
break;
|
|
195
197
|
}
|
|
196
|
-
} catch (
|
|
197
|
-
console.warn("[DevTools] Failed to parse server message:",
|
|
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(
|
|
205
|
+
handleModifyQuerySet(e) {
|
|
204
206
|
const n = Date.now();
|
|
205
|
-
for (const
|
|
206
|
-
if (
|
|
207
|
-
this.
|
|
208
|
-
queryId:
|
|
209
|
-
udfPath:
|
|
210
|
-
args:
|
|
211
|
-
componentPath:
|
|
212
|
-
|
|
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: `
|
|
223
|
+
id: this.nextEventId(`query-pending-${t.queryId}`, n),
|
|
216
224
|
timestamp: n,
|
|
217
|
-
type: "
|
|
218
|
-
queryId:
|
|
219
|
-
udfPath:
|
|
220
|
-
args:
|
|
221
|
-
componentPath:
|
|
222
|
-
status: "
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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:
|
|
230
|
-
udfPath:
|
|
231
|
-
args:
|
|
232
|
-
componentPath:
|
|
233
|
-
status: "
|
|
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 (
|
|
237
|
-
const o = this.pendingQueries.get(
|
|
238
|
-
|
|
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(
|
|
278
|
+
handleMutationRequest(e) {
|
|
257
279
|
const n = Date.now();
|
|
258
|
-
this.pendingMutations.set(
|
|
259
|
-
requestId:
|
|
260
|
-
udfPath:
|
|
261
|
-
args:
|
|
262
|
-
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
|
|
266
|
-
id: `mutation-pending-${
|
|
287
|
+
const t = {
|
|
288
|
+
id: this.nextEventId(`mutation-pending-${e.requestId}`, n),
|
|
267
289
|
timestamp: n,
|
|
268
290
|
type: "mutation",
|
|
269
|
-
requestId:
|
|
270
|
-
udfPath:
|
|
271
|
-
args:
|
|
272
|
-
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(
|
|
297
|
+
this.eventStore.addEvent(t);
|
|
276
298
|
}
|
|
277
299
|
/**
|
|
278
300
|
* Handle action requests
|
|
279
301
|
*/
|
|
280
|
-
handleActionRequest(
|
|
302
|
+
handleActionRequest(e) {
|
|
281
303
|
const n = Date.now();
|
|
282
|
-
this.pendingActions.set(
|
|
283
|
-
requestId:
|
|
284
|
-
udfPath:
|
|
285
|
-
args:
|
|
286
|
-
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
|
|
290
|
-
id: `action-pending-${
|
|
311
|
+
const t = {
|
|
312
|
+
id: this.nextEventId(`action-pending-${e.requestId}`, n),
|
|
291
313
|
timestamp: n,
|
|
292
314
|
type: "action",
|
|
293
|
-
requestId:
|
|
294
|
-
udfPath:
|
|
295
|
-
args:
|
|
296
|
-
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(
|
|
321
|
+
this.eventStore.addEvent(t);
|
|
300
322
|
}
|
|
301
|
-
handleConnectMessage(
|
|
323
|
+
handleConnectMessage(e) {
|
|
302
324
|
const n = {};
|
|
303
|
-
typeof
|
|
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(
|
|
332
|
+
handleAuthenticateMessage(e) {
|
|
311
333
|
const n = {};
|
|
312
|
-
if (typeof
|
|
313
|
-
const
|
|
314
|
-
n.tokenLength =
|
|
315
|
-
const o =
|
|
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 =
|
|
340
|
+
this.pendingAuthTokenType = e.tokenType ?? "Unknown", this.emitAuthEvent({
|
|
319
341
|
direction: "client",
|
|
320
342
|
messageType: "Authenticate",
|
|
321
343
|
status: "success",
|
|
322
|
-
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(
|
|
381
|
-
const
|
|
382
|
-
if (!
|
|
383
|
-
const o = Date.now(), s = o -
|
|
384
|
-
id: `mutation-${
|
|
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:
|
|
388
|
-
udfPath:
|
|
389
|
-
args:
|
|
390
|
-
componentPath:
|
|
391
|
-
status:
|
|
392
|
-
result:
|
|
393
|
-
error:
|
|
394
|
-
logLines:
|
|
395
|
-
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(
|
|
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(
|
|
404
|
-
const
|
|
405
|
-
if (!
|
|
406
|
-
const o = Date.now(), s = o -
|
|
407
|
-
id: `action-${
|
|
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:
|
|
411
|
-
udfPath:
|
|
412
|
-
args:
|
|
413
|
-
componentPath:
|
|
414
|
-
status:
|
|
415
|
-
result:
|
|
416
|
-
error:
|
|
417
|
-
logLines:
|
|
418
|
-
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(
|
|
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(
|
|
394
|
+
handleAuthErrorResponse(e) {
|
|
424
395
|
const n = {};
|
|
425
|
-
typeof
|
|
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:
|
|
401
|
+
error: e.error ?? "Authentication failed",
|
|
431
402
|
details: n
|
|
432
403
|
}), this.pendingAuthTokenType = null;
|
|
433
404
|
}
|
|
434
|
-
|
|
435
|
-
|
|
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:
|
|
435
|
+
duration: t,
|
|
438
436
|
simulatedDelayMs: o,
|
|
439
|
-
endToEndDurationMs:
|
|
437
|
+
endToEndDurationMs: t + o
|
|
440
438
|
};
|
|
441
439
|
}
|
|
442
|
-
emitAuthEvent(
|
|
443
|
-
const n = Date.now(),
|
|
444
|
-
id: `auth-${
|
|
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:
|
|
448
|
-
messageType:
|
|
449
|
-
status:
|
|
450
|
-
tokenType:
|
|
451
|
-
error:
|
|
452
|
-
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(
|
|
452
|
+
this.eventStore.addEvent(t);
|
|
455
453
|
}
|
|
456
454
|
/**
|
|
457
455
|
* Extract and emit log events from logLines
|
|
458
456
|
*/
|
|
459
|
-
emitLogEvents(
|
|
460
|
-
const
|
|
461
|
-
for (const o of
|
|
462
|
-
const s = o.match(/^\[(log|info|warn|error)\]\s+(.+)$/i), i = s ? s[1].toLowerCase() : "log",
|
|
463
|
-
id: `log-${
|
|
464
|
-
timestamp:
|
|
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:
|
|
465
|
+
message: r,
|
|
468
466
|
relatedEventId: n
|
|
469
467
|
};
|
|
470
|
-
this.eventStore.addEvent(
|
|
468
|
+
this.eventStore.addEvent(h);
|
|
471
469
|
}
|
|
472
470
|
}
|
|
473
471
|
}
|
|
474
472
|
export {
|
|
475
|
-
|
|
476
|
-
|
|
473
|
+
k as DataInspector,
|
|
474
|
+
L as DevToolbar,
|
|
477
475
|
A as EventStore,
|
|
478
476
|
D as LogsPanel,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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
|
};
|