@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/client-B2IPTPCG.js +2961 -0
- package/dist/client.js +1 -1
- package/dist/index.js +301 -208
- package/dist/interceptor/websocket-interceptor.d.ts +1 -0
- package/dist/overlay/ActivityPanel.d.ts +9 -1
- package/dist/overlay/DevToolbar.d.ts +9 -1
- package/dist/store/event-store.d.ts +24 -0
- package/dist/types.d.ts +33 -0
- package/dist/vite-plugin.js +279 -170
- package/package.json +5 -5
- package/dist/client-D6NyDOCN.js +0 -2781
package/dist/index.js
CHANGED
|
@@ -1,78 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
11
|
-
for (const a of
|
|
12
|
-
const
|
|
13
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
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
|
|
69
|
-
this.send = (
|
|
120
|
+
const I = this.send.bind(this);
|
|
121
|
+
this.send = (u) => {
|
|
70
122
|
try {
|
|
71
|
-
typeof
|
|
72
|
-
} catch (
|
|
73
|
-
console.warn("[DevTools] Error parsing client message:",
|
|
123
|
+
typeof u == "string" && t.handleClientMessage(u);
|
|
124
|
+
} catch (r) {
|
|
125
|
+
console.warn("[DevTools] Error parsing client message:", r);
|
|
74
126
|
}
|
|
75
|
-
|
|
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(
|
|
142
|
+
handleClientMessage(t) {
|
|
91
143
|
try {
|
|
92
|
-
const
|
|
93
|
-
switch (console.log("[DevTools] Client message:",
|
|
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(
|
|
147
|
+
this.handleModifyQuerySet(e.modifications);
|
|
96
148
|
break;
|
|
97
149
|
case "Mutation":
|
|
98
|
-
this.handleMutationRequest(
|
|
150
|
+
this.handleMutationRequest(e);
|
|
99
151
|
break;
|
|
100
152
|
case "Action":
|
|
101
|
-
this.handleActionRequest(
|
|
153
|
+
this.handleActionRequest(e);
|
|
102
154
|
break;
|
|
103
155
|
case "Connect":
|
|
104
|
-
this.handleConnectMessage(
|
|
156
|
+
this.handleConnectMessage(e);
|
|
105
157
|
break;
|
|
106
158
|
case "Authenticate":
|
|
107
|
-
this.handleAuthenticateMessage(
|
|
159
|
+
this.handleAuthenticateMessage(e);
|
|
108
160
|
break;
|
|
109
161
|
}
|
|
110
|
-
} catch (
|
|
111
|
-
console.warn("[DevTools] Failed to parse client message:",
|
|
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
|
|
120
|
-
switch (console.log("[DevTools] Server message:",
|
|
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(
|
|
174
|
+
this.handleTransition(n, e);
|
|
123
175
|
break;
|
|
124
176
|
case "MutationResponse":
|
|
125
|
-
this.handleMutationResponse(
|
|
177
|
+
this.handleMutationResponse(n, e);
|
|
126
178
|
break;
|
|
127
179
|
case "ActionResponse":
|
|
128
|
-
this.handleActionResponse(
|
|
180
|
+
this.handleActionResponse(n, e);
|
|
129
181
|
break;
|
|
130
182
|
case "AuthError":
|
|
131
|
-
this.handleAuthErrorResponse(
|
|
183
|
+
this.handleAuthErrorResponse(n);
|
|
132
184
|
break;
|
|
133
185
|
}
|
|
134
|
-
} catch (
|
|
135
|
-
console.warn("[DevTools] Failed to parse server message:",
|
|
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(
|
|
142
|
-
const
|
|
143
|
-
for (const n of
|
|
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:
|
|
202
|
+
startTime: e
|
|
151
203
|
});
|
|
152
|
-
const
|
|
153
|
-
id: `sub-${n.queryId}-${
|
|
154
|
-
timestamp:
|
|
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
|
|
165
|
-
if (this.pendingQueries.delete(n.queryId),
|
|
166
|
-
const
|
|
167
|
-
id: `sub-${n.queryId}-${
|
|
168
|
-
timestamp:
|
|
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:
|
|
172
|
-
args:
|
|
173
|
-
componentPath:
|
|
234
|
+
udfPath: o.udfPath,
|
|
235
|
+
args: o.args,
|
|
236
|
+
componentPath: o.componentPath,
|
|
174
237
|
status: "removed"
|
|
175
238
|
};
|
|
176
|
-
this.eventStore.addEvent(
|
|
239
|
+
this.eventStore.addEvent(s);
|
|
177
240
|
}
|
|
178
241
|
}
|
|
179
242
|
}
|
|
180
243
|
/**
|
|
181
244
|
* Handle mutation requests
|
|
182
245
|
*/
|
|
183
|
-
handleMutationRequest(
|
|
184
|
-
const
|
|
185
|
-
this.pendingMutations.set(
|
|
186
|
-
requestId:
|
|
187
|
-
udfPath:
|
|
188
|
-
args:
|
|
189
|
-
componentPath:
|
|
190
|
-
startTime:
|
|
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(
|
|
197
|
-
const
|
|
198
|
-
this.pendingActions.set(
|
|
199
|
-
requestId:
|
|
200
|
-
udfPath:
|
|
201
|
-
args:
|
|
202
|
-
componentPath:
|
|
203
|
-
startTime:
|
|
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(
|
|
207
|
-
const
|
|
208
|
-
typeof
|
|
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:
|
|
297
|
+
details: e
|
|
213
298
|
});
|
|
214
299
|
}
|
|
215
|
-
handleAuthenticateMessage(
|
|
216
|
-
const
|
|
217
|
-
if (typeof
|
|
218
|
-
const n =
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
|
|
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 =
|
|
308
|
+
this.pendingAuthTokenType = t.tokenType ?? "Unknown", this.emitAuthEvent({
|
|
224
309
|
direction: "client",
|
|
225
310
|
messageType: "Authenticate",
|
|
226
311
|
status: "success",
|
|
227
|
-
tokenType:
|
|
228
|
-
details:
|
|
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
|
|
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:
|
|
326
|
+
details: { modificationCount: t.modifications.length }
|
|
242
327
|
}), this.pendingAuthTokenType = null);
|
|
243
|
-
for (const
|
|
244
|
-
if (
|
|
245
|
-
const s = this.pendingQueries.get(
|
|
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
|
|
248
|
-
id: `query-${
|
|
249
|
-
timestamp:
|
|
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:
|
|
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:
|
|
257
|
-
logLines:
|
|
258
|
-
|
|
259
|
-
triggeredBy:
|
|
341
|
+
result: o.value,
|
|
342
|
+
logLines: o.logLines,
|
|
343
|
+
...a,
|
|
344
|
+
triggeredBy: d
|
|
260
345
|
};
|
|
261
|
-
this.eventStore.addEvent(
|
|
262
|
-
} else if (
|
|
263
|
-
const s = this.pendingQueries.get(
|
|
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
|
|
266
|
-
id: `query-${
|
|
267
|
-
timestamp:
|
|
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:
|
|
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:
|
|
275
|
-
logLines:
|
|
276
|
-
|
|
359
|
+
error: o.errorMessage,
|
|
360
|
+
logLines: o.logLines,
|
|
361
|
+
...a
|
|
277
362
|
};
|
|
278
|
-
this.eventStore.addEvent(
|
|
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
|
|
286
|
-
if (!
|
|
287
|
-
const
|
|
288
|
-
id: `mutation-${
|
|
289
|
-
timestamp:
|
|
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:
|
|
292
|
-
udfPath:
|
|
293
|
-
args:
|
|
294
|
-
componentPath:
|
|
295
|
-
status:
|
|
296
|
-
result:
|
|
297
|
-
error:
|
|
298
|
-
logLines:
|
|
299
|
-
|
|
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(
|
|
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
|
|
308
|
-
if (!
|
|
309
|
-
const
|
|
310
|
-
id: `action-${
|
|
311
|
-
timestamp:
|
|
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:
|
|
314
|
-
udfPath:
|
|
315
|
-
args:
|
|
316
|
-
componentPath:
|
|
317
|
-
status:
|
|
318
|
-
result:
|
|
319
|
-
error:
|
|
320
|
-
logLines:
|
|
321
|
-
|
|
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(
|
|
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(
|
|
326
|
-
const
|
|
327
|
-
typeof
|
|
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:
|
|
333
|
-
details:
|
|
417
|
+
error: t.error ?? "Authentication failed",
|
|
418
|
+
details: e
|
|
334
419
|
}), this.pendingAuthTokenType = null;
|
|
335
420
|
}
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
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:
|
|
342
|
-
messageType:
|
|
343
|
-
status:
|
|
344
|
-
tokenType:
|
|
345
|
-
error:
|
|
346
|
-
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(
|
|
446
|
+
emitLogEvents(t, e) {
|
|
354
447
|
const n = Date.now();
|
|
355
|
-
for (const
|
|
356
|
-
const
|
|
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:
|
|
455
|
+
relatedEventId: e
|
|
363
456
|
};
|
|
364
|
-
this.eventStore.addEvent(
|
|
457
|
+
this.eventStore.addEvent(d);
|
|
365
458
|
}
|
|
366
459
|
}
|
|
367
460
|
}
|
|
368
461
|
export {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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
|
};
|