@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/vite-plugin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fileURLToPath as
|
|
3
|
-
const
|
|
4
|
-
function p(
|
|
5
|
-
const { enabled:
|
|
1
|
+
import o from "path";
|
|
2
|
+
import { fileURLToPath as l } from "url";
|
|
3
|
+
const m = o.dirname(l(import.meta.url));
|
|
4
|
+
function p(s = {}) {
|
|
5
|
+
const { enabled: i = !0, position: a = "bottom-right" } = s;
|
|
6
6
|
let t = !1;
|
|
7
7
|
return {
|
|
8
8
|
name: "concave-devtools",
|
|
@@ -12,9 +12,9 @@ function p(i = {}) {
|
|
|
12
12
|
transformIndexHtml: {
|
|
13
13
|
order: "pre",
|
|
14
14
|
handler(e) {
|
|
15
|
-
if (!t || !
|
|
15
|
+
if (!t || !i)
|
|
16
16
|
return e;
|
|
17
|
-
const
|
|
17
|
+
const r = `
|
|
18
18
|
<script>
|
|
19
19
|
// Initialize event store immediately
|
|
20
20
|
(function() {
|
|
@@ -28,7 +28,56 @@ function p(i = {}) {
|
|
|
28
28
|
window.__concaveDevToolsPendingMutations = new Map();
|
|
29
29
|
window.__concaveDevToolsPendingActions = new Map();
|
|
30
30
|
window.__concaveDevToolsPendingAuthTokenType = null;
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
// Latency simulation config (mutated by devtools settings panel)
|
|
33
|
+
if (!window.__concaveDevToolsLatencyConfig) {
|
|
34
|
+
window.__concaveDevToolsLatencyConfig = { latencyMs: 0, jitterMs: 0 };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var __concaveGetLatencyDelay = function() {
|
|
38
|
+
var cfg = window.__concaveDevToolsLatencyConfig;
|
|
39
|
+
if (!cfg) return 0;
|
|
40
|
+
var base = Number(cfg.latencyMs) || 0;
|
|
41
|
+
var jitter = Number(cfg.jitterMs) || 0;
|
|
42
|
+
if (base <= 0 && jitter <= 0) return 0;
|
|
43
|
+
return Math.max(0, base + (jitter > 0 ? (Math.random() * 2 - 1) * jitter : 0));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var __concaveInternalMessageListener = Symbol.for('__concaveDevToolsInternalWsListener');
|
|
47
|
+
var __concaveLatencyDelaySymbol = Symbol.for('__concaveDevToolsWsDelayMs');
|
|
48
|
+
var __concaveGetDelayForEvent = function(event) {
|
|
49
|
+
if (!event || typeof event !== 'object') return __concaveGetLatencyDelay();
|
|
50
|
+
var existing = event[__concaveLatencyDelaySymbol];
|
|
51
|
+
if (typeof existing === 'number' && isFinite(existing) && existing >= 0) {
|
|
52
|
+
return existing;
|
|
53
|
+
}
|
|
54
|
+
var sampled = __concaveGetLatencyDelay();
|
|
55
|
+
try {
|
|
56
|
+
Object.defineProperty(event, __concaveLatencyDelaySymbol, {
|
|
57
|
+
value: sampled,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
} catch (e) {
|
|
61
|
+
event[__concaveLatencyDelaySymbol] = sampled;
|
|
62
|
+
}
|
|
63
|
+
return sampled;
|
|
64
|
+
};
|
|
65
|
+
var __concaveInvokeWithLatency = function(listener, target, event) {
|
|
66
|
+
if (typeof listener !== 'function') return;
|
|
67
|
+
if (listener[__concaveInternalMessageListener]) {
|
|
68
|
+
listener.call(target, event);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var delay = __concaveGetDelayForEvent(event);
|
|
72
|
+
if (delay > 0) {
|
|
73
|
+
setTimeout(function() {
|
|
74
|
+
listener.call(target, event);
|
|
75
|
+
}, delay);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
listener.call(target, event);
|
|
79
|
+
};
|
|
80
|
+
|
|
32
81
|
const OriginalWebSocket = window.WebSocket;
|
|
33
82
|
|
|
34
83
|
const emitAuthEvent = (direction, messageType, status, details, error, tokenType) => {
|
|
@@ -69,7 +118,7 @@ function p(i = {}) {
|
|
|
69
118
|
// Create intercepted WebSocket constructor
|
|
70
119
|
window.WebSocket = function(url, protocols) {
|
|
71
120
|
const ws = new OriginalWebSocket(url, protocols);
|
|
72
|
-
|
|
121
|
+
|
|
73
122
|
// Intercept send
|
|
74
123
|
const originalSend = ws.send.bind(ws);
|
|
75
124
|
ws.send = function(data) {
|
|
@@ -125,6 +174,17 @@ function p(i = {}) {
|
|
|
125
174
|
componentPath: mod.componentPath,
|
|
126
175
|
status: 'added'
|
|
127
176
|
});
|
|
177
|
+
|
|
178
|
+
window.__concaveDevToolsEvents.push({
|
|
179
|
+
id: 'query-pending-' + mod.queryId + '-' + now,
|
|
180
|
+
timestamp: now,
|
|
181
|
+
type: 'query',
|
|
182
|
+
queryId: mod.queryId,
|
|
183
|
+
udfPath: mod.udfPath,
|
|
184
|
+
args: mod.args,
|
|
185
|
+
componentPath: mod.componentPath,
|
|
186
|
+
status: 'pending'
|
|
187
|
+
});
|
|
128
188
|
} else if (mod.type === 'Remove') {
|
|
129
189
|
const pending = window.__concaveDevToolsPendingQueries.get(mod.queryId);
|
|
130
190
|
window.__concaveDevToolsPendingQueries.delete(mod.queryId);
|
|
@@ -152,6 +212,17 @@ function p(i = {}) {
|
|
|
152
212
|
componentPath: msg.componentPath,
|
|
153
213
|
startTime: now
|
|
154
214
|
});
|
|
215
|
+
|
|
216
|
+
window.__concaveDevToolsEvents.push({
|
|
217
|
+
id: 'mutation-pending-' + msg.requestId + '-' + now,
|
|
218
|
+
timestamp: now,
|
|
219
|
+
type: 'mutation',
|
|
220
|
+
requestId: msg.requestId,
|
|
221
|
+
udfPath: msg.udfPath,
|
|
222
|
+
args: msg.args,
|
|
223
|
+
componentPath: msg.componentPath,
|
|
224
|
+
status: 'pending'
|
|
225
|
+
});
|
|
155
226
|
}
|
|
156
227
|
|
|
157
228
|
// Track actions
|
|
@@ -163,6 +234,17 @@ function p(i = {}) {
|
|
|
163
234
|
componentPath: msg.componentPath,
|
|
164
235
|
startTime: now
|
|
165
236
|
});
|
|
237
|
+
|
|
238
|
+
window.__concaveDevToolsEvents.push({
|
|
239
|
+
id: 'action-pending-' + msg.requestId + '-' + now,
|
|
240
|
+
timestamp: now,
|
|
241
|
+
type: 'action',
|
|
242
|
+
requestId: msg.requestId,
|
|
243
|
+
udfPath: msg.udfPath,
|
|
244
|
+
args: msg.args,
|
|
245
|
+
componentPath: msg.componentPath,
|
|
246
|
+
status: 'pending'
|
|
247
|
+
});
|
|
166
248
|
}
|
|
167
249
|
} catch (e) {
|
|
168
250
|
console.warn('[DevTools] Error parsing client message:', e);
|
|
@@ -171,171 +253,194 @@ function p(i = {}) {
|
|
|
171
253
|
return originalSend(data);
|
|
172
254
|
};
|
|
173
255
|
|
|
174
|
-
// Intercept message
|
|
256
|
+
// Intercept message handlers and keep listener identity stable so removeEventListener works.
|
|
175
257
|
const originalAddEventListener = ws.addEventListener.bind(ws);
|
|
258
|
+
const originalRemoveEventListener = ws.removeEventListener.bind(ws);
|
|
259
|
+
const messageListenerWrappers = new WeakMap();
|
|
176
260
|
ws.addEventListener = function(type, listener, options) {
|
|
177
261
|
if (type === 'message' && typeof listener === 'function') {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
262
|
+
let wrappedListener = messageListenerWrappers.get(listener);
|
|
263
|
+
if (!wrappedListener) {
|
|
264
|
+
wrappedListener = function(event) {
|
|
265
|
+
try {
|
|
266
|
+
const msg = JSON.parse(event.data);
|
|
267
|
+
const now = Date.now();
|
|
268
|
+
const delayMs = __concaveGetDelayForEvent(event);
|
|
182
269
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
window.__concaveDevToolsPendingAuthTokenType = null;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Handle transitions (query updates)
|
|
192
|
-
if (msg.type === 'Transition' && msg.modifications) {
|
|
193
|
-
if (window.__concaveDevToolsPendingAuthTokenType) {
|
|
194
|
-
emitAuthEvent(
|
|
195
|
-
'server',
|
|
196
|
-
'Authenticated',
|
|
197
|
-
'success',
|
|
198
|
-
{ modificationCount: msg.modifications.length },
|
|
199
|
-
undefined,
|
|
200
|
-
window.__concaveDevToolsPendingAuthTokenType
|
|
201
|
-
);
|
|
270
|
+
if (msg.type === 'AuthError') {
|
|
271
|
+
const errorDetails = {};
|
|
272
|
+
if (typeof msg.baseVersion === 'number') errorDetails.baseVersion = msg.baseVersion;
|
|
273
|
+
if (typeof msg.authUpdateAttempted === 'boolean') errorDetails.authUpdateAttempted = msg.authUpdateAttempted;
|
|
274
|
+
emitAuthEvent('server', 'AuthError', 'error', errorDetails, msg.error || 'Authentication failed', window.__concaveDevToolsPendingAuthTokenType || undefined);
|
|
202
275
|
window.__concaveDevToolsPendingAuthTokenType = null;
|
|
203
276
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
277
|
+
|
|
278
|
+
// Handle transitions (query updates)
|
|
279
|
+
if (msg.type === 'Transition' && msg.modifications) {
|
|
280
|
+
if (window.__concaveDevToolsPendingAuthTokenType) {
|
|
281
|
+
emitAuthEvent(
|
|
282
|
+
'server',
|
|
283
|
+
'Authenticated',
|
|
284
|
+
'success',
|
|
285
|
+
{ modificationCount: msg.modifications.length },
|
|
286
|
+
undefined,
|
|
287
|
+
window.__concaveDevToolsPendingAuthTokenType
|
|
288
|
+
);
|
|
289
|
+
window.__concaveDevToolsPendingAuthTokenType = null;
|
|
290
|
+
}
|
|
291
|
+
msg.modifications.forEach(mod => {
|
|
292
|
+
if (mod.type === 'QueryUpdated' || mod.type === 'QueryFailed') {
|
|
293
|
+
const pending = window.__concaveDevToolsPendingQueries.get(mod.queryId);
|
|
294
|
+
if (pending) {
|
|
295
|
+
const duration = now - pending.startTime;
|
|
296
|
+
window.__concaveDevToolsEvents.push({
|
|
297
|
+
id: 'query-' + mod.queryId + '-' + now,
|
|
298
|
+
timestamp: now,
|
|
299
|
+
type: 'query',
|
|
300
|
+
queryId: mod.queryId,
|
|
301
|
+
udfPath: pending.udfPath,
|
|
302
|
+
args: pending.args,
|
|
303
|
+
componentPath: pending.componentPath,
|
|
304
|
+
status: mod.type === 'QueryUpdated' ? 'success' : 'error',
|
|
305
|
+
result: mod.type === 'QueryUpdated' ? mod.value : undefined,
|
|
306
|
+
error: mod.type === 'QueryFailed' ? mod.errorMessage : undefined,
|
|
307
|
+
logLines: mod.logLines,
|
|
308
|
+
duration: duration,
|
|
309
|
+
simulatedDelayMs: delayMs,
|
|
310
|
+
endToEndDurationMs: duration + delayMs
|
|
238
311
|
});
|
|
312
|
+
|
|
313
|
+
// Extract log events
|
|
314
|
+
if (mod.logLines && mod.logLines.length > 0) {
|
|
315
|
+
mod.logLines.forEach(logLine => {
|
|
316
|
+
const match = logLine.match(/^\\[(log|info|warn|error)\\]\\s+(.+)$/i);
|
|
317
|
+
const level = match ? match[1].toLowerCase() : 'log';
|
|
318
|
+
const message = match ? match[2] : logLine;
|
|
319
|
+
window.__concaveDevToolsEvents.push({
|
|
320
|
+
id: 'log-' + now + '-' + Math.random(),
|
|
321
|
+
timestamp: now,
|
|
322
|
+
type: 'log',
|
|
323
|
+
level: level,
|
|
324
|
+
message: message,
|
|
325
|
+
relatedEventId: 'query-' + mod.queryId + '-' + now
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
}
|
|
239
329
|
}
|
|
240
330
|
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Handle mutation responses
|
|
246
|
-
if (msg.type === 'MutationResponse') {
|
|
247
|
-
const pending = window.__concaveDevToolsPendingMutations.get(msg.requestId);
|
|
248
|
-
if (pending) {
|
|
249
|
-
const duration = now - pending.startTime;
|
|
250
|
-
window.__concaveDevToolsEvents.push({
|
|
251
|
-
id: 'mutation-' + msg.requestId + '-' + now,
|
|
252
|
-
timestamp: now,
|
|
253
|
-
type: 'mutation',
|
|
254
|
-
requestId: msg.requestId,
|
|
255
|
-
udfPath: pending.udfPath,
|
|
256
|
-
args: pending.args,
|
|
257
|
-
componentPath: pending.componentPath,
|
|
258
|
-
status: msg.success ? 'success' : 'error',
|
|
259
|
-
result: msg.success ? msg.result : undefined,
|
|
260
|
-
error: !msg.success ? msg.result : undefined,
|
|
261
|
-
logLines: msg.logLines,
|
|
262
|
-
duration: duration
|
|
263
331
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Handle mutation responses
|
|
335
|
+
if (msg.type === 'MutationResponse') {
|
|
336
|
+
const pending = window.__concaveDevToolsPendingMutations.get(msg.requestId);
|
|
337
|
+
if (pending) {
|
|
338
|
+
const duration = now - pending.startTime;
|
|
339
|
+
window.__concaveDevToolsEvents.push({
|
|
340
|
+
id: 'mutation-' + msg.requestId + '-' + now,
|
|
341
|
+
timestamp: now,
|
|
342
|
+
type: 'mutation',
|
|
343
|
+
requestId: msg.requestId,
|
|
344
|
+
udfPath: pending.udfPath,
|
|
345
|
+
args: pending.args,
|
|
346
|
+
componentPath: pending.componentPath,
|
|
347
|
+
status: msg.success ? 'success' : 'error',
|
|
348
|
+
result: msg.success ? msg.result : undefined,
|
|
349
|
+
error: !msg.success ? msg.result : undefined,
|
|
350
|
+
logLines: msg.logLines,
|
|
351
|
+
duration: duration,
|
|
352
|
+
simulatedDelayMs: delayMs,
|
|
353
|
+
endToEndDurationMs: duration + delayMs
|
|
279
354
|
});
|
|
355
|
+
|
|
356
|
+
// Extract log events
|
|
357
|
+
if (msg.logLines && msg.logLines.length > 0) {
|
|
358
|
+
msg.logLines.forEach(logLine => {
|
|
359
|
+
const match = logLine.match(/^\\[(log|info|warn|error)\\]\\s+(.+)$/i);
|
|
360
|
+
const level = match ? match[1].toLowerCase() : 'log';
|
|
361
|
+
const message = match ? match[2] : logLine;
|
|
362
|
+
window.__concaveDevToolsEvents.push({
|
|
363
|
+
id: 'log-' + now + '-' + Math.random(),
|
|
364
|
+
timestamp: now,
|
|
365
|
+
type: 'log',
|
|
366
|
+
level: level,
|
|
367
|
+
message: message,
|
|
368
|
+
relatedEventId: 'mutation-' + msg.requestId + '-' + now
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
window.__concaveDevToolsPendingMutations.delete(msg.requestId);
|
|
280
374
|
}
|
|
281
|
-
|
|
282
|
-
window.__concaveDevToolsPendingMutations.delete(msg.requestId);
|
|
283
375
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
// Extract log events
|
|
307
|
-
if (msg.logLines && msg.logLines.length > 0) {
|
|
308
|
-
msg.logLines.forEach(logLine => {
|
|
309
|
-
const match = logLine.match(/^\\[(log|info|warn|error)\\]\\s+(.+)$/i);
|
|
310
|
-
const level = match ? match[1].toLowerCase() : 'log';
|
|
311
|
-
const message = match ? match[2] : logLine;
|
|
312
|
-
window.__concaveDevToolsEvents.push({
|
|
313
|
-
id: 'log-' + now + '-' + Math.random(),
|
|
314
|
-
timestamp: now,
|
|
315
|
-
type: 'log',
|
|
316
|
-
level: level,
|
|
317
|
-
message: message,
|
|
318
|
-
relatedEventId: 'action-' + msg.requestId + '-' + now
|
|
319
|
-
});
|
|
376
|
+
|
|
377
|
+
// Handle action responses
|
|
378
|
+
if (msg.type === 'ActionResponse') {
|
|
379
|
+
const pending = window.__concaveDevToolsPendingActions.get(msg.requestId);
|
|
380
|
+
if (pending) {
|
|
381
|
+
const duration = now - pending.startTime;
|
|
382
|
+
window.__concaveDevToolsEvents.push({
|
|
383
|
+
id: 'action-' + msg.requestId + '-' + now,
|
|
384
|
+
timestamp: now,
|
|
385
|
+
type: 'action',
|
|
386
|
+
requestId: msg.requestId,
|
|
387
|
+
udfPath: pending.udfPath,
|
|
388
|
+
args: pending.args,
|
|
389
|
+
componentPath: pending.componentPath,
|
|
390
|
+
status: msg.success ? 'success' : 'error',
|
|
391
|
+
result: msg.success ? msg.result : undefined,
|
|
392
|
+
error: !msg.success ? msg.result : undefined,
|
|
393
|
+
logLines: msg.logLines,
|
|
394
|
+
duration: duration,
|
|
395
|
+
simulatedDelayMs: delayMs,
|
|
396
|
+
endToEndDurationMs: duration + delayMs
|
|
320
397
|
});
|
|
398
|
+
|
|
399
|
+
// Extract log events
|
|
400
|
+
if (msg.logLines && msg.logLines.length > 0) {
|
|
401
|
+
msg.logLines.forEach(logLine => {
|
|
402
|
+
const match = logLine.match(/^\\[(log|info|warn|error)\\]\\s+(.+)$/i);
|
|
403
|
+
const level = match ? match[1].toLowerCase() : 'log';
|
|
404
|
+
const message = match ? match[2] : logLine;
|
|
405
|
+
window.__concaveDevToolsEvents.push({
|
|
406
|
+
id: 'log-' + now + '-' + Math.random(),
|
|
407
|
+
timestamp: now,
|
|
408
|
+
type: 'log',
|
|
409
|
+
level: level,
|
|
410
|
+
message: message,
|
|
411
|
+
relatedEventId: 'action-' + msg.requestId + '-' + now
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
window.__concaveDevToolsPendingActions.delete(msg.requestId);
|
|
321
417
|
}
|
|
322
|
-
|
|
323
|
-
window.__concaveDevToolsPendingActions.delete(msg.requestId);
|
|
324
418
|
}
|
|
419
|
+
} catch (e) {
|
|
420
|
+
console.warn('[DevTools] Error parsing server message:', e);
|
|
325
421
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
422
|
+
__concaveInvokeWithLatency(listener, ws, event);
|
|
423
|
+
};
|
|
424
|
+
wrappedListener[__concaveInternalMessageListener] = true;
|
|
425
|
+
messageListenerWrappers.set(listener, wrappedListener);
|
|
426
|
+
}
|
|
331
427
|
return originalAddEventListener('message', wrappedListener, options);
|
|
332
428
|
}
|
|
333
429
|
return originalAddEventListener(type, listener, options);
|
|
334
430
|
};
|
|
335
431
|
|
|
432
|
+
ws.removeEventListener = function(type, listener, options) {
|
|
433
|
+
if (type === 'message' && typeof listener === 'function') {
|
|
434
|
+
const wrappedListener = messageListenerWrappers.get(listener);
|
|
435
|
+
return originalRemoveEventListener('message', wrappedListener || listener, options);
|
|
436
|
+
}
|
|
437
|
+
return originalRemoveEventListener(type, listener, options);
|
|
438
|
+
};
|
|
439
|
+
|
|
336
440
|
// Intercept onmessage assignment as well
|
|
337
441
|
(function(){
|
|
338
442
|
let currentHandler = null;
|
|
443
|
+
let currentOnMessageWrapper = null;
|
|
339
444
|
Object.defineProperty(ws, 'onmessage', {
|
|
340
445
|
configurable: true,
|
|
341
446
|
enumerable: true,
|
|
@@ -344,8 +449,9 @@ function p(i = {}) {
|
|
|
344
449
|
},
|
|
345
450
|
set(handler) {
|
|
346
451
|
// Remove previous wrapper if present
|
|
347
|
-
if (
|
|
348
|
-
|
|
452
|
+
if (currentOnMessageWrapper) {
|
|
453
|
+
originalRemoveEventListener('message', currentOnMessageWrapper);
|
|
454
|
+
currentOnMessageWrapper = null;
|
|
349
455
|
}
|
|
350
456
|
currentHandler = handler;
|
|
351
457
|
if (typeof handler === 'function') {
|
|
@@ -353,6 +459,7 @@ function p(i = {}) {
|
|
|
353
459
|
try {
|
|
354
460
|
const msg = JSON.parse(event.data);
|
|
355
461
|
const now = Date.now();
|
|
462
|
+
const delayMs = __concaveGetDelayForEvent(event);
|
|
356
463
|
|
|
357
464
|
if (msg.type === 'AuthError') {
|
|
358
465
|
const errorDetails = {};
|
|
@@ -392,7 +499,9 @@ function p(i = {}) {
|
|
|
392
499
|
result: mod.type === 'QueryUpdated' ? mod.value : undefined,
|
|
393
500
|
error: mod.type === 'QueryFailed' ? mod.errorMessage : undefined,
|
|
394
501
|
logLines: mod.logLines,
|
|
395
|
-
duration: duration
|
|
502
|
+
duration: duration,
|
|
503
|
+
simulatedDelayMs: delayMs,
|
|
504
|
+
endToEndDurationMs: duration + delayMs
|
|
396
505
|
});
|
|
397
506
|
if (mod.logLines && mod.logLines.length > 0) {
|
|
398
507
|
mod.logLines.forEach(logLine => {
|
|
@@ -429,7 +538,9 @@ function p(i = {}) {
|
|
|
429
538
|
result: msg.success ? msg.result : undefined,
|
|
430
539
|
error: !msg.success ? msg.result : undefined,
|
|
431
540
|
logLines: msg.logLines,
|
|
432
|
-
duration: duration
|
|
541
|
+
duration: duration,
|
|
542
|
+
simulatedDelayMs: delayMs,
|
|
543
|
+
endToEndDurationMs: duration + delayMs
|
|
433
544
|
});
|
|
434
545
|
if (msg.logLines && msg.logLines.length > 0) {
|
|
435
546
|
msg.logLines.forEach(logLine => {
|
|
@@ -465,7 +576,9 @@ function p(i = {}) {
|
|
|
465
576
|
result: msg.success ? msg.result : undefined,
|
|
466
577
|
error: !msg.success ? msg.result : undefined,
|
|
467
578
|
logLines: msg.logLines,
|
|
468
|
-
duration: duration
|
|
579
|
+
duration: duration,
|
|
580
|
+
simulatedDelayMs: delayMs,
|
|
581
|
+
endToEndDurationMs: duration + delayMs
|
|
469
582
|
});
|
|
470
583
|
if (msg.logLines && msg.logLines.length > 0) {
|
|
471
584
|
msg.logLines.forEach(logLine => {
|
|
@@ -488,14 +601,11 @@ function p(i = {}) {
|
|
|
488
601
|
} catch (e) {
|
|
489
602
|
console.warn('[DevTools] Error parsing server message (onmessage):', e);
|
|
490
603
|
}
|
|
491
|
-
|
|
492
|
-
handler.call(ws, event);
|
|
493
|
-
}
|
|
604
|
+
__concaveInvokeWithLatency(handler, ws, event);
|
|
494
605
|
};
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
(ws).__concaveOnMessageWrapper = null;
|
|
606
|
+
wrapper[__concaveInternalMessageListener] = true;
|
|
607
|
+
currentOnMessageWrapper = wrapper;
|
|
608
|
+
originalAddEventListener('message', wrapper);
|
|
499
609
|
}
|
|
500
610
|
}
|
|
501
611
|
});
|
|
@@ -503,36 +613,35 @@ function p(i = {}) {
|
|
|
503
613
|
|
|
504
614
|
return ws;
|
|
505
615
|
};
|
|
506
|
-
|
|
616
|
+
|
|
507
617
|
// Preserve prototype chain
|
|
508
618
|
Object.setPrototypeOf(window.WebSocket, OriginalWebSocket);
|
|
509
|
-
Object.defineProperty(window.WebSocket, 'prototype', {
|
|
619
|
+
Object.defineProperty(window.WebSocket, 'prototype', {
|
|
510
620
|
value: OriginalWebSocket.prototype,
|
|
511
621
|
writable: false,
|
|
512
622
|
configurable: false
|
|
513
623
|
});
|
|
514
|
-
|
|
624
|
+
|
|
515
625
|
console.log('[DevTools] WebSocket interceptor installed');
|
|
516
626
|
})();
|
|
517
627
|
<\/script>
|
|
518
628
|
`, d = `
|
|
519
629
|
<script>
|
|
520
|
-
window.__concaveDevToolsConfig = ${JSON.stringify({ position:
|
|
630
|
+
window.__concaveDevToolsConfig = ${JSON.stringify({ position: a, autoInit: !0 })};
|
|
521
631
|
<\/script>
|
|
522
632
|
`, c = `
|
|
523
633
|
<script type="module">
|
|
524
|
-
import { initDevTools } from '/@fs${
|
|
634
|
+
import { initDevTools } from '/@fs${o.resolve(m, "../client.tsx").replace(/\\/g, "/")}';
|
|
525
635
|
<\/script>
|
|
526
|
-
`,
|
|
527
|
-
return e.includes("</head>") ? e.replace("</head>", `${
|
|
636
|
+
`, n = r + d + c;
|
|
637
|
+
return e.includes("</head>") ? e.replace("</head>", `${n}</head>`) : e.includes("</body>") ? e.replace("</body>", `${n}</body>`) : e + n;
|
|
528
638
|
}
|
|
529
639
|
},
|
|
530
640
|
// Ensure devtools dependencies are optimized
|
|
531
641
|
config(e) {
|
|
532
|
-
var n;
|
|
533
642
|
return {
|
|
534
643
|
optimizeDeps: {
|
|
535
|
-
include: [...
|
|
644
|
+
include: [...e.optimizeDeps?.include || [], "react", "react-dom"]
|
|
536
645
|
}
|
|
537
646
|
};
|
|
538
647
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@concavejs/devtools",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.6",
|
|
4
4
|
"license": "FSL-1.1-Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"type-check": "tsc --noEmit"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@concavejs/brand": "0.0.1-alpha.
|
|
42
|
-
"@concavejs/core": "0.0.1-alpha.
|
|
41
|
+
"@concavejs/brand": "0.0.1-alpha.6",
|
|
42
|
+
"@concavejs/core": "0.0.1-alpha.6"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^18.0.0",
|
|
46
46
|
"react-dom": "^18.0.0",
|
|
47
|
-
"vite": "^
|
|
47
|
+
"vite": "^7.1.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@tailwindcss/vite": "^4.1.18",
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"tailwindcss": "^4.1.18",
|
|
58
58
|
"terser": "^5.46.0",
|
|
59
59
|
"typescript": "^5.3.0",
|
|
60
|
-
"vite": "^
|
|
60
|
+
"vite": "^7.1.2"
|
|
61
61
|
}
|
|
62
62
|
}
|