@buoy-gg/events 7.0.40 → 7.0.42
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/README.md +11 -60
- package/lib/commonjs/components/EventsCopySettingsView.js +1 -581
- package/lib/commonjs/components/EventsModal.js +1 -387
- package/lib/commonjs/components/ReactQueryEventDetail.js +1 -433
- package/lib/commonjs/components/UnifiedEventDetail.js +1 -556
- package/lib/commonjs/components/UnifiedEventFilters.js +1 -160
- package/lib/commonjs/components/UnifiedEventItem.js +1 -417
- package/lib/commonjs/components/UnifiedEventList.js +1 -187
- package/lib/commonjs/components/UnifiedEventViewer.js +1 -130
- package/lib/commonjs/hooks/useUnifiedEvents.js +1 -419
- package/lib/commonjs/index.js +1 -282
- package/lib/commonjs/preset.js +1 -60
- package/lib/commonjs/sources/sourceIds.js +1 -30
- package/lib/commonjs/stores/unifiedEventStore.js +1 -712
- package/lib/commonjs/sync/eventsSyncAdapter.js +1 -358
- package/lib/commonjs/types/copySettings.js +1 -249
- package/lib/commonjs/types/index.js +1 -17
- package/lib/commonjs/utils/autoDiscoverEventSources.js +1 -1065
- package/lib/commonjs/utils/badgeSelectionStorage.js +1 -126
- package/lib/commonjs/utils/copySettingsStorage.js +1 -43
- package/lib/commonjs/utils/correlationUtils.js +1 -130
- package/lib/commonjs/utils/eventExportFormatter.js +1 -1912
- package/lib/commonjs/utils/eventTransformers.js +1 -496
- package/lib/commonjs/utils/eventVisibility.js +1 -76
- package/lib/commonjs/utils/testIDs.js +1 -91
- package/lib/module/components/EventsCopySettingsView.js +1 -577
- package/lib/module/components/EventsModal.js +1 -383
- package/lib/module/components/ReactQueryEventDetail.js +1 -429
- package/lib/module/components/UnifiedEventDetail.js +1 -552
- package/lib/module/components/UnifiedEventFilters.js +1 -156
- package/lib/module/components/UnifiedEventItem.js +1 -413
- package/lib/module/components/UnifiedEventList.js +1 -183
- package/lib/module/components/UnifiedEventViewer.js +1 -126
- package/lib/module/hooks/useUnifiedEvents.js +1 -416
- package/lib/module/index.js +1 -102
- package/lib/module/preset.js +1 -57
- package/lib/module/sources/sourceIds.js +1 -26
- package/lib/module/stores/unifiedEventStore.js +1 -678
- package/lib/module/sync/eventsSyncAdapter.js +1 -354
- package/lib/module/types/copySettings.js +1 -244
- package/lib/module/types/index.js +1 -37
- package/lib/module/utils/autoDiscoverEventSources.js +1 -1057
- package/lib/module/utils/badgeSelectionStorage.js +1 -116
- package/lib/module/utils/copySettingsStorage.js +1 -37
- package/lib/module/utils/correlationUtils.js +1 -120
- package/lib/module/utils/eventExportFormatter.js +1 -1901
- package/lib/module/utils/eventTransformers.js +1 -487
- package/lib/module/utils/eventVisibility.js +1 -70
- package/lib/module/utils/testIDs.js +1 -83
- package/lib/typescript/components/EventsModal.d.ts +1 -7
- package/lib/typescript/components/UnifiedEventDetail.d.ts +2 -9
- package/lib/typescript/components/UnifiedEventItem.d.ts +0 -7
- package/lib/web/index.mjs +12 -0
- package/package.json +31 -11
- package/lib/commonjs/components/EventsCopySettingsView.js.map +0 -1
- package/lib/commonjs/components/EventsModal.js.map +0 -1
- package/lib/commonjs/components/ReactQueryEventDetail.js.map +0 -1
- package/lib/commonjs/components/UnifiedEventDetail.js.map +0 -1
- package/lib/commonjs/components/UnifiedEventFilters.js.map +0 -1
- package/lib/commonjs/components/UnifiedEventItem.js.map +0 -1
- package/lib/commonjs/components/UnifiedEventList.js.map +0 -1
- package/lib/commonjs/components/UnifiedEventViewer.js.map +0 -1
- package/lib/commonjs/hooks/useUnifiedEvents.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/preset.js.map +0 -1
- package/lib/commonjs/sources/sourceIds.js.map +0 -1
- package/lib/commonjs/stores/unifiedEventStore.js.map +0 -1
- package/lib/commonjs/sync/eventsSyncAdapter.js.map +0 -1
- package/lib/commonjs/types/copySettings.js.map +0 -1
- package/lib/commonjs/types/index.js.map +0 -1
- package/lib/commonjs/utils/autoDiscoverEventSources.js.map +0 -1
- package/lib/commonjs/utils/badgeSelectionStorage.js.map +0 -1
- package/lib/commonjs/utils/copySettingsStorage.js.map +0 -1
- package/lib/commonjs/utils/correlationUtils.js.map +0 -1
- package/lib/commonjs/utils/eventExportFormatter.js.map +0 -1
- package/lib/commonjs/utils/eventTransformers.js.map +0 -1
- package/lib/commonjs/utils/eventVisibility.js.map +0 -1
- package/lib/commonjs/utils/testIDs.js.map +0 -1
- package/lib/module/components/EventsCopySettingsView.js.map +0 -1
- package/lib/module/components/EventsModal.js.map +0 -1
- package/lib/module/components/ReactQueryEventDetail.js.map +0 -1
- package/lib/module/components/UnifiedEventDetail.js.map +0 -1
- package/lib/module/components/UnifiedEventFilters.js.map +0 -1
- package/lib/module/components/UnifiedEventItem.js.map +0 -1
- package/lib/module/components/UnifiedEventList.js.map +0 -1
- package/lib/module/components/UnifiedEventViewer.js.map +0 -1
- package/lib/module/hooks/useUnifiedEvents.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/preset.js.map +0 -1
- package/lib/module/sources/sourceIds.js.map +0 -1
- package/lib/module/stores/unifiedEventStore.js.map +0 -1
- package/lib/module/sync/eventsSyncAdapter.js.map +0 -1
- package/lib/module/types/copySettings.js.map +0 -1
- package/lib/module/types/index.js.map +0 -1
- package/lib/module/utils/autoDiscoverEventSources.js.map +0 -1
- package/lib/module/utils/badgeSelectionStorage.js.map +0 -1
- package/lib/module/utils/copySettingsStorage.js.map +0 -1
- package/lib/module/utils/correlationUtils.js.map +0 -1
- package/lib/module/utils/eventExportFormatter.js.map +0 -1
- package/lib/module/utils/eventTransformers.js.map +0 -1
- package/lib/module/utils/eventVisibility.js.map +0 -1
- package/lib/module/utils/testIDs.js.map +0 -1
- package/lib/typescript/components/EventsCopySettingsView.d.ts.map +0 -1
- package/lib/typescript/components/EventsModal.d.ts.map +0 -1
- package/lib/typescript/components/ReactQueryEventDetail.d.ts.map +0 -1
- package/lib/typescript/components/UnifiedEventDetail.d.ts.map +0 -1
- package/lib/typescript/components/UnifiedEventFilters.d.ts.map +0 -1
- package/lib/typescript/components/UnifiedEventItem.d.ts.map +0 -1
- package/lib/typescript/components/UnifiedEventList.d.ts.map +0 -1
- package/lib/typescript/components/UnifiedEventViewer.d.ts.map +0 -1
- package/lib/typescript/hooks/useUnifiedEvents.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/sources/sourceIds.d.ts.map +0 -1
- package/lib/typescript/stores/unifiedEventStore.d.ts.map +0 -1
- package/lib/typescript/sync/eventsSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/types/copySettings.d.ts.map +0 -1
- package/lib/typescript/types/index.d.ts.map +0 -1
- package/lib/typescript/utils/autoDiscoverEventSources.d.ts.map +0 -1
- package/lib/typescript/utils/badgeSelectionStorage.d.ts.map +0 -1
- package/lib/typescript/utils/copySettingsStorage.d.ts.map +0 -1
- package/lib/typescript/utils/correlationUtils.d.ts.map +0 -1
- package/lib/typescript/utils/eventExportFormatter.d.ts.map +0 -1
- package/lib/typescript/utils/eventTransformers.d.ts.map +0 -1
- package/lib/typescript/utils/eventVisibility.d.ts.map +0 -1
- package/lib/typescript/utils/testIDs.d.ts.map +0 -1
|
@@ -1,1057 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Auto-Discover Event Sources
|
|
5
|
-
*
|
|
6
|
-
* Automatically discovers and loads event stores from installed packages.
|
|
7
|
-
* Uses try-catch pattern to safely handle missing packages - if a tool
|
|
8
|
-
* isn't installed, it's silently skipped.
|
|
9
|
-
*
|
|
10
|
-
* This enables zero-config setup - just install the dev tool packages you
|
|
11
|
-
* want and they'll automatically appear in the unified events timeline!
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// ============================================================================
|
|
15
|
-
// Types for discovered event sources
|
|
16
|
-
// ============================================================================
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Configuration for a discovered event source
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Result of auto-discovery
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
// ============================================================================
|
|
27
|
-
// Event transformers (inline to avoid import dependencies)
|
|
28
|
-
// ============================================================================
|
|
29
|
-
|
|
30
|
-
let eventIdCounter = 0;
|
|
31
|
-
function generateEventId(source) {
|
|
32
|
-
return `${source}-${Date.now()}-${++eventIdCounter}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// ============================================================================
|
|
36
|
-
// Storage Event Source Discovery
|
|
37
|
-
// ============================================================================
|
|
38
|
-
|
|
39
|
-
function tryLoadStorageSource() {
|
|
40
|
-
try {
|
|
41
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
42
|
-
const {
|
|
43
|
-
storageEventStore
|
|
44
|
-
} = require("@buoy-gg/storage");
|
|
45
|
-
return {
|
|
46
|
-
id: "storage",
|
|
47
|
-
name: "Storage",
|
|
48
|
-
eventSources: ["storage-async", "storage-mmkv"],
|
|
49
|
-
available: true,
|
|
50
|
-
// No setup needed - onEvent() auto-starts capturing via Subscribable pattern
|
|
51
|
-
subscribe: onEvent => {
|
|
52
|
-
return storageEventStore.onEvent(event => {
|
|
53
|
-
// The store's initial scan synthesizes a `setItem` for every key
|
|
54
|
-
// already on disk (so the STORAGE tool's state views include
|
|
55
|
-
// pre-existing keys). In a TIMELINE those read as dozens of writes
|
|
56
|
-
// that never happened — stamped with the scan moment, so the first
|
|
57
|
-
// subscribe after a quiet boot (i.e. the user pressing the power
|
|
58
|
-
// button on an empty, just-cleared list) instantly "captured" ~60
|
|
59
|
-
// events. This timeline reports what happens, not what exists.
|
|
60
|
-
const data = event?.data;
|
|
61
|
-
if (data?.initialScan) return;
|
|
62
|
-
const unifiedEvent = transformStorageEvent(event);
|
|
63
|
-
onEvent(unifiedEvent);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
} catch {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function transformStorageEvent(event) {
|
|
72
|
-
const e = event;
|
|
73
|
-
const source = e.storageType === "async" ? "storage-async" : "storage-mmkv";
|
|
74
|
-
|
|
75
|
-
// Get action label
|
|
76
|
-
let title = e.action;
|
|
77
|
-
if (e.storageType === "async") {
|
|
78
|
-
const labelMap = {
|
|
79
|
-
setItem: "Set Item",
|
|
80
|
-
removeItem: "Remove Item",
|
|
81
|
-
mergeItem: "Merge Item",
|
|
82
|
-
clear: "Clear All",
|
|
83
|
-
multiSet: "Multi Set",
|
|
84
|
-
multiRemove: "Multi Remove",
|
|
85
|
-
multiMerge: "Multi Merge"
|
|
86
|
-
};
|
|
87
|
-
title = labelMap[e.action] || e.action;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Get subtitle
|
|
91
|
-
let subtitle = "";
|
|
92
|
-
if (e.storageType === "async") {
|
|
93
|
-
switch (e.action) {
|
|
94
|
-
case "setItem":
|
|
95
|
-
case "removeItem":
|
|
96
|
-
case "mergeItem":
|
|
97
|
-
subtitle = e.data?.key || "unknown key";
|
|
98
|
-
break;
|
|
99
|
-
case "multiSet":
|
|
100
|
-
case "multiMerge":
|
|
101
|
-
{
|
|
102
|
-
const pairCount = e.data?.pairs?.length || 0;
|
|
103
|
-
subtitle = `${pairCount} key${pairCount !== 1 ? "s" : ""}`;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case "multiRemove":
|
|
107
|
-
{
|
|
108
|
-
const keyCount = e.data?.keys?.length || 0;
|
|
109
|
-
subtitle = `${keyCount} key${keyCount !== 1 ? "s" : ""}`;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case "clear":
|
|
113
|
-
subtitle = "all keys";
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
subtitle = e.data?.key || e.data?.instanceId || "unknown";
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Get status
|
|
121
|
-
let status = "neutral";
|
|
122
|
-
if (e.action.includes("set") || e.action.includes("Set") || e.action.includes("merge") || e.action.includes("Merge")) {
|
|
123
|
-
status = "success";
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
id: generateEventId(source),
|
|
127
|
-
source,
|
|
128
|
-
timestamp: e.timestamp.getTime(),
|
|
129
|
-
title,
|
|
130
|
-
subtitle,
|
|
131
|
-
status,
|
|
132
|
-
originalEvent: event
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ============================================================================
|
|
137
|
-
// Redux Event Source Discovery
|
|
138
|
-
// ============================================================================
|
|
139
|
-
|
|
140
|
-
function tryLoadReduxSource() {
|
|
141
|
-
try {
|
|
142
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
143
|
-
const {
|
|
144
|
-
reduxActionStore
|
|
145
|
-
} = require("@buoy-gg/redux");
|
|
146
|
-
let lastActionId = null;
|
|
147
|
-
return {
|
|
148
|
-
id: "redux",
|
|
149
|
-
name: "Redux",
|
|
150
|
-
eventSources: ["redux"],
|
|
151
|
-
available: true,
|
|
152
|
-
subscribe: onEvent => {
|
|
153
|
-
return reduxActionStore.subscribe(actions => {
|
|
154
|
-
if (actions.length > 0) {
|
|
155
|
-
const latestAction = actions[0];
|
|
156
|
-
if (latestAction.id !== lastActionId) {
|
|
157
|
-
lastActionId = latestAction.id;
|
|
158
|
-
const unifiedEvent = transformReduxAction(latestAction);
|
|
159
|
-
onEvent(unifiedEvent);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
} catch {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function transformReduxAction(action) {
|
|
170
|
-
const a = action;
|
|
171
|
-
|
|
172
|
-
// Get status
|
|
173
|
-
let status = "neutral";
|
|
174
|
-
switch (a.category) {
|
|
175
|
-
case "fulfilled":
|
|
176
|
-
status = "success";
|
|
177
|
-
break;
|
|
178
|
-
case "rejected":
|
|
179
|
-
status = "error";
|
|
180
|
-
break;
|
|
181
|
-
case "pending":
|
|
182
|
-
status = "pending";
|
|
183
|
-
break;
|
|
184
|
-
default:
|
|
185
|
-
status = a.hasStateChange ? "success" : "neutral";
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Get subtitle
|
|
189
|
-
let subtitle = "";
|
|
190
|
-
if (a.payloadPreview) {
|
|
191
|
-
subtitle = a.payloadPreview;
|
|
192
|
-
} else if (a.hasStateChange && a.diffSummary) {
|
|
193
|
-
subtitle = a.diffSummary;
|
|
194
|
-
} else if (a.duration !== undefined) {
|
|
195
|
-
subtitle = `${a.duration.toFixed(1)}ms`;
|
|
196
|
-
} else {
|
|
197
|
-
subtitle = a.sliceName || "";
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
id: generateEventId("redux"),
|
|
201
|
-
source: "redux",
|
|
202
|
-
timestamp: a.timestamp,
|
|
203
|
-
title: a.type,
|
|
204
|
-
subtitle,
|
|
205
|
-
status,
|
|
206
|
-
originalEvent: action
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// ============================================================================
|
|
211
|
-
// Network Event Source Discovery
|
|
212
|
-
// ============================================================================
|
|
213
|
-
|
|
214
|
-
function tryLoadNetworkSource() {
|
|
215
|
-
try {
|
|
216
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
217
|
-
// Note: We use networkListener (the getter) instead of startNetworkListener
|
|
218
|
-
// because startNetworkListener is not exported from the main package
|
|
219
|
-
const {
|
|
220
|
-
networkEventStore,
|
|
221
|
-
networkListener,
|
|
222
|
-
addNetworkListener
|
|
223
|
-
} = require("@buoy-gg/network");
|
|
224
|
-
|
|
225
|
-
// Map network event IDs to unified event IDs for updates (request -> response)
|
|
226
|
-
const networkEventIdMap = new Map();
|
|
227
|
-
return {
|
|
228
|
-
id: "network",
|
|
229
|
-
name: "Network",
|
|
230
|
-
eventSources: ["network"],
|
|
231
|
-
available: true,
|
|
232
|
-
setup: () => {
|
|
233
|
-
// Get the network listener singleton and start it if not already active
|
|
234
|
-
const listener = networkListener();
|
|
235
|
-
if (!listener.isActive) {
|
|
236
|
-
listener.startListening();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Ensure events flow into the store. The network panel does this via
|
|
240
|
-
// addNetworkListener, but if events package loads first, we need to
|
|
241
|
-
// set it up ourselves.
|
|
242
|
-
if (listener.listenerCount === 0) {
|
|
243
|
-
addNetworkListener(event => {
|
|
244
|
-
networkEventStore.processNetworkEvent(event);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
subscribe: onEvent => {
|
|
249
|
-
// Use onEvent() pattern - same as storage
|
|
250
|
-
// This fires for each individual event (request or response/error update)
|
|
251
|
-
// Pass replayExisting=false to avoid replaying up to 500 buffered events
|
|
252
|
-
// synchronously, which causes ~30s UI freezes from mass state updates.
|
|
253
|
-
//
|
|
254
|
-
// replayExisting=false is not the whole story though: the store's
|
|
255
|
-
// boot-capture buffer parks raw interceptor events until the FIRST
|
|
256
|
-
// consumer subscribes, then flushes them through addEvent — so a
|
|
257
|
-
// subscribe can still be handed traffic from before it existed (three
|
|
258
|
-
// boot requests landing as "live" rows the instant the power button
|
|
259
|
-
// was pressed). The network TOOL wants that history; a timeline does
|
|
260
|
-
// not. Both emissions of a request carry the request's start time, so
|
|
261
|
-
// dropping NEW rows stamped before this subscription filters exactly
|
|
262
|
-
// the history (an update to a row we already made still flows).
|
|
263
|
-
const subscribedAt = Date.now();
|
|
264
|
-
return networkEventStore.onEvent(event => {
|
|
265
|
-
const ne = event;
|
|
266
|
-
const existingUnifiedId = networkEventIdMap.get(ne.id);
|
|
267
|
-
if (!existingUnifiedId) {
|
|
268
|
-
if (typeof ne.timestamp === "number" && ne.timestamp < subscribedAt) {
|
|
269
|
-
return; // pre-subscription history (boot buffer / paused gap)
|
|
270
|
-
}
|
|
271
|
-
// New event (request started)
|
|
272
|
-
const unifiedEvent = transformNetworkEvent(event);
|
|
273
|
-
networkEventIdMap.set(ne.id, unifiedEvent.id);
|
|
274
|
-
onEvent(unifiedEvent);
|
|
275
|
-
} else {
|
|
276
|
-
// Existing event updated (response received or error)
|
|
277
|
-
const unifiedEvent = transformNetworkEvent(event);
|
|
278
|
-
unifiedEvent.id = existingUnifiedId; // Keep the same unified ID
|
|
279
|
-
onEvent(unifiedEvent);
|
|
280
|
-
}
|
|
281
|
-
}, false);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
} catch {
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
function transformNetworkEvent(event) {
|
|
289
|
-
const e = event;
|
|
290
|
-
|
|
291
|
-
// Get status
|
|
292
|
-
let status = "neutral";
|
|
293
|
-
if (e.status === undefined) {
|
|
294
|
-
status = "pending";
|
|
295
|
-
} else if (e.error || e.status >= 400) {
|
|
296
|
-
status = "error";
|
|
297
|
-
} else if (e.status >= 200 && e.status < 400) {
|
|
298
|
-
status = "success";
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Get title
|
|
302
|
-
const title = e.operationName || `${e.method} ${e.path || e.url}`;
|
|
303
|
-
|
|
304
|
-
// Get subtitle
|
|
305
|
-
const parts = [];
|
|
306
|
-
if (e.status !== undefined) {
|
|
307
|
-
parts.push(`${e.status}`);
|
|
308
|
-
} else if (e.error) {
|
|
309
|
-
parts.push("Error");
|
|
310
|
-
} else {
|
|
311
|
-
parts.push("Pending");
|
|
312
|
-
}
|
|
313
|
-
if (e.duration !== undefined) {
|
|
314
|
-
parts.push(`${e.duration.toFixed(0)}ms`);
|
|
315
|
-
}
|
|
316
|
-
if (e.host) {
|
|
317
|
-
parts.push(e.host);
|
|
318
|
-
}
|
|
319
|
-
return {
|
|
320
|
-
id: generateEventId("network"),
|
|
321
|
-
source: "network",
|
|
322
|
-
timestamp: e.timestamp,
|
|
323
|
-
title,
|
|
324
|
-
subtitle: parts.join(" · "),
|
|
325
|
-
status,
|
|
326
|
-
originalEvent: event
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ============================================================================
|
|
331
|
-
// React Query Event Source Discovery
|
|
332
|
-
// ============================================================================
|
|
333
|
-
|
|
334
|
-
function tryLoadReactQuerySource() {
|
|
335
|
-
try {
|
|
336
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
337
|
-
const {
|
|
338
|
-
reactQueryEventStore
|
|
339
|
-
} = require("@buoy-gg/react-query");
|
|
340
|
-
let lastEventId = null;
|
|
341
|
-
return {
|
|
342
|
-
id: "react-query",
|
|
343
|
-
name: "React Query",
|
|
344
|
-
eventSources: ["react-query", "react-query-query", "react-query-mutation"],
|
|
345
|
-
available: true,
|
|
346
|
-
subscribe: onEvent => {
|
|
347
|
-
// Unlike the redux/zustand/jotai stores, this store's subscribe()
|
|
348
|
-
// SYNCHRONOUSLY replays its current buffer to the new listener — and
|
|
349
|
-
// ReactQueryTracker feeds that buffer from app start, before anything
|
|
350
|
-
// here listens. That first call is history; emitting its latest entry
|
|
351
|
-
// made a boot-time fetch appear as a fresh event at every first
|
|
352
|
-
// open / pause→resume. Prime the guard from it and emit nothing.
|
|
353
|
-
let priming = true;
|
|
354
|
-
// Starts seen by THIS subscription. A fetch is start + settle under
|
|
355
|
-
// one hash, and a settle whose start predates the subscription is the
|
|
356
|
-
// second half of history — a boot fetch on a slow network settling
|
|
357
|
-
// seconds after the tool opened used to land as a bare "Success" the
|
|
358
|
-
// moment capture began. Same rule the network source applies to a
|
|
359
|
-
// request sent before its subscription.
|
|
360
|
-
const seenStarts = new Set();
|
|
361
|
-
const fetchIdentity = e => e.queryHash ?? (e.mutationId !== undefined ? `m-${e.mutationId}` : null);
|
|
362
|
-
return reactQueryEventStore.subscribe(events => {
|
|
363
|
-
if (priming) {
|
|
364
|
-
priming = false;
|
|
365
|
-
if (events.length > 0) {
|
|
366
|
-
lastEventId = events[0].id;
|
|
367
|
-
}
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (events.length > 0) {
|
|
371
|
-
const latestEvent = events[0];
|
|
372
|
-
if (latestEvent.id !== lastEventId) {
|
|
373
|
-
lastEventId = latestEvent.id;
|
|
374
|
-
const type = latestEvent.type ?? "";
|
|
375
|
-
const identity = fetchIdentity(latestEvent);
|
|
376
|
-
if (type === "query-fetch-start" || type === "mutation-start") {
|
|
377
|
-
if (identity) seenStarts.add(identity);
|
|
378
|
-
} else if (type === "query-fetch-success" || type === "query-fetch-error" || type === "mutation-success" || type === "mutation-error") {
|
|
379
|
-
if (identity && !seenStarts.has(identity)) {
|
|
380
|
-
return; // settle of a fetch begun before this subscription
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
const unifiedEvent = transformReactQueryEvent(latestEvent);
|
|
384
|
-
onEvent(unifiedEvent);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
} catch {
|
|
391
|
-
return null;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
function formatQueryKey(queryKey) {
|
|
395
|
-
if (!queryKey || queryKey.length === 0) return "unknown";
|
|
396
|
-
return queryKey.map(part => {
|
|
397
|
-
if (typeof part === "string") return part;
|
|
398
|
-
if (typeof part === "number") return String(part);
|
|
399
|
-
if (typeof part === "object" && part !== null) {
|
|
400
|
-
const obj = part;
|
|
401
|
-
const firstValue = Object.values(obj)[0];
|
|
402
|
-
if (typeof firstValue === "string" || typeof firstValue === "number") {
|
|
403
|
-
return String(firstValue);
|
|
404
|
-
}
|
|
405
|
-
return JSON.stringify(part).slice(0, 20);
|
|
406
|
-
}
|
|
407
|
-
return String(part);
|
|
408
|
-
}).join(" › ");
|
|
409
|
-
}
|
|
410
|
-
function transformReactQueryEvent(event) {
|
|
411
|
-
const e = event;
|
|
412
|
-
const isMutation = e.type.startsWith("mutation-");
|
|
413
|
-
const source = isMutation ? "react-query-mutation" : "react-query-query";
|
|
414
|
-
|
|
415
|
-
// Get status
|
|
416
|
-
let status = "neutral";
|
|
417
|
-
switch (e.type) {
|
|
418
|
-
case "query-fetch-start":
|
|
419
|
-
case "mutation-start":
|
|
420
|
-
status = "pending";
|
|
421
|
-
break;
|
|
422
|
-
case "query-fetch-success":
|
|
423
|
-
case "mutation-success":
|
|
424
|
-
status = "success";
|
|
425
|
-
break;
|
|
426
|
-
case "query-fetch-error":
|
|
427
|
-
case "mutation-error":
|
|
428
|
-
status = "error";
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Get title
|
|
433
|
-
let title = "";
|
|
434
|
-
if (e.queryKey) {
|
|
435
|
-
title = formatQueryKey(e.queryKey);
|
|
436
|
-
} else if (e.mutationKey) {
|
|
437
|
-
title = formatQueryKey(e.mutationKey);
|
|
438
|
-
} else if (e.mutationId !== undefined) {
|
|
439
|
-
title = `Mutation #${e.mutationId}`;
|
|
440
|
-
} else {
|
|
441
|
-
title = e.type.replace(/-/g, " ");
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// Get subtitle
|
|
445
|
-
const parts = [];
|
|
446
|
-
switch (e.type) {
|
|
447
|
-
case "query-fetch-start":
|
|
448
|
-
parts.push("Fetching");
|
|
449
|
-
break;
|
|
450
|
-
case "query-fetch-success":
|
|
451
|
-
parts.push("Success");
|
|
452
|
-
break;
|
|
453
|
-
case "query-fetch-error":
|
|
454
|
-
parts.push("Error");
|
|
455
|
-
break;
|
|
456
|
-
case "query-invalidated":
|
|
457
|
-
parts.push("Invalidated");
|
|
458
|
-
break;
|
|
459
|
-
case "mutation-start":
|
|
460
|
-
parts.push("Mutating");
|
|
461
|
-
break;
|
|
462
|
-
case "mutation-success":
|
|
463
|
-
parts.push("Success");
|
|
464
|
-
break;
|
|
465
|
-
case "mutation-error":
|
|
466
|
-
parts.push("Error");
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
if (e.duration !== undefined) {
|
|
470
|
-
parts.push(`${e.duration.toFixed(0)}ms`);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// Get correlation info
|
|
474
|
-
let correlationId;
|
|
475
|
-
if (e.queryHash) {
|
|
476
|
-
correlationId = `rq-query-${e.queryHash}`;
|
|
477
|
-
} else if (e.mutationId !== undefined) {
|
|
478
|
-
correlationId = `rq-mutation-${e.mutationId}`;
|
|
479
|
-
}
|
|
480
|
-
let sequenceInGroup = 1;
|
|
481
|
-
switch (e.type) {
|
|
482
|
-
case "query-fetch-start":
|
|
483
|
-
case "mutation-start":
|
|
484
|
-
sequenceInGroup = 1;
|
|
485
|
-
break;
|
|
486
|
-
case "query-fetch-success":
|
|
487
|
-
case "query-fetch-error":
|
|
488
|
-
case "mutation-success":
|
|
489
|
-
case "mutation-error":
|
|
490
|
-
sequenceInGroup = 2;
|
|
491
|
-
break;
|
|
492
|
-
case "query-invalidated":
|
|
493
|
-
sequenceInGroup = 3;
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
return {
|
|
497
|
-
id: generateEventId(source),
|
|
498
|
-
source,
|
|
499
|
-
timestamp: e.timestamp,
|
|
500
|
-
title,
|
|
501
|
-
subtitle: parts.join(" · "),
|
|
502
|
-
status,
|
|
503
|
-
originalEvent: event,
|
|
504
|
-
correlationId,
|
|
505
|
-
sequenceInGroup
|
|
506
|
-
};
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
// ============================================================================
|
|
510
|
-
// Route Events Source Discovery
|
|
511
|
-
// ============================================================================
|
|
512
|
-
|
|
513
|
-
function tryLoadRouteEventsSource() {
|
|
514
|
-
try {
|
|
515
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
516
|
-
const {
|
|
517
|
-
routeEventStore
|
|
518
|
-
} = require("@buoy-gg/route-events");
|
|
519
|
-
return {
|
|
520
|
-
id: "route-events",
|
|
521
|
-
name: "Routes",
|
|
522
|
-
eventSources: ["route"],
|
|
523
|
-
available: true,
|
|
524
|
-
// No setup needed - onEvent() auto-starts listening via Subscribable pattern
|
|
525
|
-
subscribe: onEvent => {
|
|
526
|
-
return routeEventStore.onEvent(event => {
|
|
527
|
-
const unifiedEvent = transformRouteEvent(event);
|
|
528
|
-
onEvent(unifiedEvent);
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
} catch {
|
|
533
|
-
return null;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
function transformRouteEvent(event) {
|
|
537
|
-
const e = event;
|
|
538
|
-
|
|
539
|
-
// Get status
|
|
540
|
-
let status = "neutral";
|
|
541
|
-
if (e.pathname === "/") {
|
|
542
|
-
status = "success";
|
|
543
|
-
} else if (Object.keys(e.params).length > 0) {
|
|
544
|
-
status = "success";
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// Get subtitle
|
|
548
|
-
const parts = [];
|
|
549
|
-
const paramCount = Object.keys(e.params).length;
|
|
550
|
-
if (paramCount > 0) {
|
|
551
|
-
parts.push(`${paramCount} param${paramCount !== 1 ? "s" : ""}`);
|
|
552
|
-
}
|
|
553
|
-
if (e.timeSincePrevious !== undefined && e.timeSincePrevious > 0) {
|
|
554
|
-
if (e.timeSincePrevious < 1000) {
|
|
555
|
-
parts.push(`${e.timeSincePrevious}ms`);
|
|
556
|
-
} else {
|
|
557
|
-
parts.push(`${(e.timeSincePrevious / 1000).toFixed(1)}s`);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
if (e.previousPathname && e.previousPathname !== e.pathname) {
|
|
561
|
-
parts.push(`from ${e.previousPathname}`);
|
|
562
|
-
}
|
|
563
|
-
return {
|
|
564
|
-
id: generateEventId("route"),
|
|
565
|
-
source: "route",
|
|
566
|
-
timestamp: e.timestamp,
|
|
567
|
-
title: e.pathname || "/",
|
|
568
|
-
subtitle: parts.join(" · ") || "navigation",
|
|
569
|
-
status,
|
|
570
|
-
originalEvent: event
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// ============================================================================
|
|
575
|
-
// Zustand Event Source Discovery
|
|
576
|
-
// ============================================================================
|
|
577
|
-
|
|
578
|
-
function tryLoadZustandSource() {
|
|
579
|
-
try {
|
|
580
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
581
|
-
const {
|
|
582
|
-
zustandStateStore
|
|
583
|
-
} = require("@buoy-gg/zustand");
|
|
584
|
-
let lastChangeId = null;
|
|
585
|
-
return {
|
|
586
|
-
id: "zustand",
|
|
587
|
-
name: "Zustand",
|
|
588
|
-
eventSources: ["zustand"],
|
|
589
|
-
available: true,
|
|
590
|
-
subscribe: onEvent => {
|
|
591
|
-
return zustandStateStore.subscribe(changes => {
|
|
592
|
-
if (changes.length > 0) {
|
|
593
|
-
const latestChange = changes[0];
|
|
594
|
-
if (latestChange.id !== lastChangeId) {
|
|
595
|
-
lastChangeId = latestChange.id;
|
|
596
|
-
const unifiedEvent = transformZustandChange(latestChange);
|
|
597
|
-
onEvent(unifiedEvent);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
} catch {
|
|
604
|
-
return null;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
function transformZustandChange(change) {
|
|
608
|
-
const c = change;
|
|
609
|
-
|
|
610
|
-
// Get status
|
|
611
|
-
let status = "neutral";
|
|
612
|
-
if (c.isSlowUpdate) {
|
|
613
|
-
status = "pending"; // Yellow for slow updates
|
|
614
|
-
} else if (c.hasStateChange) {
|
|
615
|
-
status = "success";
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// Get subtitle
|
|
619
|
-
const parts = [];
|
|
620
|
-
if (c.changedKeys && c.changedKeys.length > 0) {
|
|
621
|
-
const keys = c.changedKeys.slice(0, 3).join(", ");
|
|
622
|
-
const more = c.changedKeys.length > 3 ? ` +${c.changedKeys.length - 3}` : "";
|
|
623
|
-
parts.push(`${keys}${more}`);
|
|
624
|
-
} else if (c.diffSummary) {
|
|
625
|
-
parts.push(c.diffSummary);
|
|
626
|
-
}
|
|
627
|
-
if (c.duration !== undefined) {
|
|
628
|
-
parts.push(`${c.duration.toFixed(1)}ms`);
|
|
629
|
-
}
|
|
630
|
-
if (c.category === "replace") {
|
|
631
|
-
parts.push("replace");
|
|
632
|
-
}
|
|
633
|
-
return {
|
|
634
|
-
id: generateEventId("zustand"),
|
|
635
|
-
source: "zustand",
|
|
636
|
-
timestamp: c.timestamp,
|
|
637
|
-
title: c.storeName,
|
|
638
|
-
subtitle: parts.join(" · ") || (c.hasStateChange ? "state changed" : "no change"),
|
|
639
|
-
status,
|
|
640
|
-
originalEvent: change
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// ============================================================================
|
|
645
|
-
// Jotai Event Source Discovery
|
|
646
|
-
// ============================================================================
|
|
647
|
-
|
|
648
|
-
function tryLoadJotaiSource() {
|
|
649
|
-
try {
|
|
650
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
651
|
-
const {
|
|
652
|
-
jotaiStateStore
|
|
653
|
-
} = require("@buoy-gg/jotai");
|
|
654
|
-
let lastChangeId = null;
|
|
655
|
-
return {
|
|
656
|
-
id: "jotai",
|
|
657
|
-
name: "Jotai",
|
|
658
|
-
eventSources: ["jotai"],
|
|
659
|
-
available: true,
|
|
660
|
-
subscribe: onEvent => {
|
|
661
|
-
return jotaiStateStore.subscribe(changes => {
|
|
662
|
-
if (changes.length > 0) {
|
|
663
|
-
const latestChange = changes[0];
|
|
664
|
-
if (latestChange.id !== lastChangeId) {
|
|
665
|
-
lastChangeId = latestChange.id;
|
|
666
|
-
const unifiedEvent = transformJotaiChange(latestChange);
|
|
667
|
-
onEvent(unifiedEvent);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
} catch {
|
|
674
|
-
return null;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
function transformJotaiChange(change) {
|
|
678
|
-
const c = change;
|
|
679
|
-
|
|
680
|
-
// Get status
|
|
681
|
-
let status = "neutral";
|
|
682
|
-
if (c.category === "write" && c.hasValueChange) {
|
|
683
|
-
status = "success";
|
|
684
|
-
} else if (c.category === "read") {
|
|
685
|
-
status = "neutral";
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// Get subtitle
|
|
689
|
-
const parts = [];
|
|
690
|
-
if (c.valuePreview) {
|
|
691
|
-
parts.push(c.valuePreview);
|
|
692
|
-
} else if (c.diffSummary) {
|
|
693
|
-
parts.push(c.diffSummary);
|
|
694
|
-
}
|
|
695
|
-
if (c.category) {
|
|
696
|
-
parts.push(c.category);
|
|
697
|
-
}
|
|
698
|
-
return {
|
|
699
|
-
id: generateEventId("jotai"),
|
|
700
|
-
source: "jotai",
|
|
701
|
-
timestamp: c.timestamp,
|
|
702
|
-
title: c.atomLabel,
|
|
703
|
-
subtitle: parts.join(" · ") || (c.hasValueChange ? "value changed" : "no change"),
|
|
704
|
-
status,
|
|
705
|
-
originalEvent: change
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// ============================================================================
|
|
710
|
-
// Render Events Source Discovery (Highlight Updates)
|
|
711
|
-
// ============================================================================
|
|
712
|
-
|
|
713
|
-
function tryLoadHighlightUpdatesSource() {
|
|
714
|
-
// Metro only treats a require() as optional when the statement sits DIRECTLY
|
|
715
|
-
// inside a single-level try block — a require nested in a closure (even one
|
|
716
|
-
// defined inside a try) fails the bundle when the package isn't installed.
|
|
717
|
-
// So: require once here, and let the callbacks below close over the result.
|
|
718
|
-
let highlightUpdates;
|
|
719
|
-
try {
|
|
720
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
721
|
-
highlightUpdates = require("@buoy-gg/highlight-updates");
|
|
722
|
-
} catch {
|
|
723
|
-
return null;
|
|
724
|
-
}
|
|
725
|
-
try {
|
|
726
|
-
// Verify the required exports exist
|
|
727
|
-
if (!highlightUpdates.RenderTracker || !highlightUpdates.HighlightUpdatesController) {
|
|
728
|
-
return null;
|
|
729
|
-
}
|
|
730
|
-
const {
|
|
731
|
-
RenderTracker,
|
|
732
|
-
HighlightUpdatesController
|
|
733
|
-
} = highlightUpdates;
|
|
734
|
-
return {
|
|
735
|
-
id: "render",
|
|
736
|
-
name: "Render",
|
|
737
|
-
eventSources: ["render"],
|
|
738
|
-
available: true,
|
|
739
|
-
setup: () => {
|
|
740
|
-
// Enable background tracking (NOT the visual toggle) - this sets up render
|
|
741
|
-
// interception without affecting the user's visual highlight toggle state
|
|
742
|
-
if (HighlightUpdatesController) {
|
|
743
|
-
HighlightUpdatesController.enableBackgroundTracking();
|
|
744
|
-
}
|
|
745
|
-
},
|
|
746
|
-
subscribe: onEvent => {
|
|
747
|
-
// Ensure background tracking is enabled (separate from visual toggle)
|
|
748
|
-
if (HighlightUpdatesController && !HighlightUpdatesController.isBackgroundTrackingEnabled()) {
|
|
749
|
-
HighlightUpdatesController.enableBackgroundTracking();
|
|
750
|
-
}
|
|
751
|
-
const unsubscribeCallback = RenderTracker.onRenderEvent((event, render) => {
|
|
752
|
-
const unifiedEvent = transformRenderEvent(event, render);
|
|
753
|
-
onEvent(unifiedEvent);
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
// Return a wrapped unsubscribe that also disables background tracking
|
|
757
|
-
return () => {
|
|
758
|
-
unsubscribeCallback();
|
|
759
|
-
HighlightUpdatesController.disableBackgroundTracking();
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
} catch {
|
|
764
|
-
return null;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
function transformRenderEvent(event, render) {
|
|
768
|
-
const e = event;
|
|
769
|
-
const r = render;
|
|
770
|
-
|
|
771
|
-
// Use component name if available, otherwise display name (View, Text, etc.)
|
|
772
|
-
const title = r.componentName || r.displayName || r.viewType;
|
|
773
|
-
|
|
774
|
-
// Build subtitle from cause info
|
|
775
|
-
const subtitleParts = [];
|
|
776
|
-
|
|
777
|
-
// Add cause type
|
|
778
|
-
const causeLabels = {
|
|
779
|
-
mount: "mounted",
|
|
780
|
-
props: "props changed",
|
|
781
|
-
state: "state changed",
|
|
782
|
-
hooks: "hooks changed",
|
|
783
|
-
context: "context changed",
|
|
784
|
-
parent: "parent re-rendered",
|
|
785
|
-
unknown: "re-rendered"
|
|
786
|
-
};
|
|
787
|
-
subtitleParts.push(causeLabels[e.cause.type] || e.cause.type);
|
|
788
|
-
|
|
789
|
-
// Add changed keys if props changed
|
|
790
|
-
if (e.cause.type === "props" && e.cause.changedKeys?.length) {
|
|
791
|
-
const keys = e.cause.changedKeys.slice(0, 3).join(", ");
|
|
792
|
-
const more = e.cause.changedKeys.length > 3 ? ` +${e.cause.changedKeys.length - 3}` : "";
|
|
793
|
-
subtitleParts.push(`[${keys}${more}]`);
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
// Add hook change description if available
|
|
797
|
-
if (e.cause.hookChanges?.length) {
|
|
798
|
-
const firstChange = e.cause.hookChanges[0];
|
|
799
|
-
if (firstChange.description) {
|
|
800
|
-
subtitleParts.push(firstChange.description);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
// Add render number
|
|
805
|
-
subtitleParts.push(`#${e.renderNumber}`);
|
|
806
|
-
|
|
807
|
-
// Determine status based on cause type
|
|
808
|
-
let status = "neutral";
|
|
809
|
-
switch (e.cause.type) {
|
|
810
|
-
case "mount":
|
|
811
|
-
status = "neutral"; // First render is expected
|
|
812
|
-
break;
|
|
813
|
-
case "props":
|
|
814
|
-
case "state":
|
|
815
|
-
case "hooks":
|
|
816
|
-
case "context":
|
|
817
|
-
status = "success"; // Intentional re-renders
|
|
818
|
-
break;
|
|
819
|
-
case "parent":
|
|
820
|
-
status = "pending"; // Potentially wasteful (yellow highlight)
|
|
821
|
-
break;
|
|
822
|
-
default:
|
|
823
|
-
status = "neutral";
|
|
824
|
-
}
|
|
825
|
-
return {
|
|
826
|
-
id: generateEventId("render"),
|
|
827
|
-
source: "render",
|
|
828
|
-
timestamp: e.timestamp,
|
|
829
|
-
title,
|
|
830
|
-
subtitle: subtitleParts.join(" · "),
|
|
831
|
-
status,
|
|
832
|
-
originalEvent: {
|
|
833
|
-
event: e,
|
|
834
|
-
render: r
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
// ============================================================================
|
|
840
|
-
// Main Auto-Discovery Function
|
|
841
|
-
// ============================================================================
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* Automatically discovers which event source packages are installed.
|
|
845
|
-
*
|
|
846
|
-
* This function attempts to load event stores from known dev tool packages.
|
|
847
|
-
* If a package is installed, its event source will be available.
|
|
848
|
-
* If a package is not installed, it will be silently skipped.
|
|
849
|
-
*
|
|
850
|
-
* @returns Discovery result with all available sources
|
|
851
|
-
*
|
|
852
|
-
* @example
|
|
853
|
-
* ```tsx
|
|
854
|
-
* const { sources, availableEventSources } = autoDiscoverEventSources();
|
|
855
|
-
*
|
|
856
|
-
* // sources contains all available event source configs
|
|
857
|
-
* // availableEventSources contains the Set of EventSource types available
|
|
858
|
-
* ```
|
|
859
|
-
*/
|
|
860
|
-
export function autoDiscoverEventSources() {
|
|
861
|
-
const sources = [];
|
|
862
|
-
const availableEventSources = new Set();
|
|
863
|
-
|
|
864
|
-
// Try to load each source
|
|
865
|
-
const loaders = [tryLoadStorageSource, tryLoadReduxSource, tryLoadNetworkSource, tryLoadReactQuerySource, tryLoadRouteEventsSource, tryLoadZustandSource, tryLoadJotaiSource, tryLoadHighlightUpdatesSource];
|
|
866
|
-
for (const loader of loaders) {
|
|
867
|
-
const source = loader();
|
|
868
|
-
if (source && source.available) {
|
|
869
|
-
sources.push(source);
|
|
870
|
-
source.eventSources.forEach(es => availableEventSources.add(es));
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
return {
|
|
874
|
-
sources,
|
|
875
|
-
availableEventSources
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
/**
|
|
880
|
-
* Get display configuration for an event source.
|
|
881
|
-
* Returns config even for unavailable sources (for consistent UI).
|
|
882
|
-
*/
|
|
883
|
-
export function getSourceDisplayConfig(source) {
|
|
884
|
-
const configs = {
|
|
885
|
-
"storage-async": {
|
|
886
|
-
label: "Storage",
|
|
887
|
-
color: "#8B5CF6",
|
|
888
|
-
icon: "server-outline"
|
|
889
|
-
},
|
|
890
|
-
"storage-mmkv": {
|
|
891
|
-
label: "MMKV",
|
|
892
|
-
color: "#F59E0B",
|
|
893
|
-
icon: "flash-outline"
|
|
894
|
-
},
|
|
895
|
-
redux: {
|
|
896
|
-
label: "Redux",
|
|
897
|
-
color: "#3B82F6",
|
|
898
|
-
icon: "git-branch-outline"
|
|
899
|
-
},
|
|
900
|
-
network: {
|
|
901
|
-
label: "Network",
|
|
902
|
-
color: "#10B981",
|
|
903
|
-
icon: "globe-outline"
|
|
904
|
-
},
|
|
905
|
-
"react-query": {
|
|
906
|
-
label: "Query",
|
|
907
|
-
color: "#EC4899",
|
|
908
|
-
icon: "sync-outline"
|
|
909
|
-
},
|
|
910
|
-
"react-query-query": {
|
|
911
|
-
label: "Query",
|
|
912
|
-
color: "#EC4899",
|
|
913
|
-
icon: "sync-outline"
|
|
914
|
-
},
|
|
915
|
-
"react-query-mutation": {
|
|
916
|
-
label: "Mutation",
|
|
917
|
-
color: "#F97316",
|
|
918
|
-
icon: "flash-outline"
|
|
919
|
-
},
|
|
920
|
-
route: {
|
|
921
|
-
label: "Route",
|
|
922
|
-
color: "#06B6D4",
|
|
923
|
-
icon: "navigate-outline"
|
|
924
|
-
},
|
|
925
|
-
zustand: {
|
|
926
|
-
label: "Zustand",
|
|
927
|
-
color: "#764ABC",
|
|
928
|
-
icon: "cube-outline"
|
|
929
|
-
},
|
|
930
|
-
jotai: {
|
|
931
|
-
label: "Jotai",
|
|
932
|
-
color: "#14B8A6",
|
|
933
|
-
icon: "ellipse-outline"
|
|
934
|
-
},
|
|
935
|
-
render: {
|
|
936
|
-
label: "Render",
|
|
937
|
-
color: "#F472B6",
|
|
938
|
-
icon: "layers-outline"
|
|
939
|
-
}
|
|
940
|
-
};
|
|
941
|
-
return configs[source] || {
|
|
942
|
-
label: source,
|
|
943
|
-
color: "#6B7280",
|
|
944
|
-
icon: "help-outline"
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
// Cache for discovered sources (singleton)
|
|
949
|
-
let cachedDiscovery = null;
|
|
950
|
-
|
|
951
|
-
/**
|
|
952
|
-
* Get cached discovery result, or run discovery if not cached.
|
|
953
|
-
* Use this for performance - avoids repeated require() calls.
|
|
954
|
-
*/
|
|
955
|
-
export function getCachedDiscovery() {
|
|
956
|
-
if (!cachedDiscovery) {
|
|
957
|
-
cachedDiscovery = autoDiscoverEventSources();
|
|
958
|
-
}
|
|
959
|
-
return cachedDiscovery;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
/**
|
|
963
|
-
* Clear the discovery cache (useful for testing or hot reload).
|
|
964
|
-
*/
|
|
965
|
-
export function clearDiscoveryCache() {
|
|
966
|
-
cachedDiscovery = null;
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
// ============================================================================
|
|
970
|
-
// Subscriber Count Aggregation
|
|
971
|
-
// ============================================================================
|
|
972
|
-
|
|
973
|
-
/**
|
|
974
|
-
* Get subscriber counts from all discovered event stores.
|
|
975
|
-
* Useful for debugging and monitoring the event system.
|
|
976
|
-
*/
|
|
977
|
-
export function getAggregatedSubscriberCounts() {
|
|
978
|
-
const sources = [];
|
|
979
|
-
let totalSubscribers = 0;
|
|
980
|
-
|
|
981
|
-
// Try to get counts from storage store
|
|
982
|
-
try {
|
|
983
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
984
|
-
const {
|
|
985
|
-
storageEventStore
|
|
986
|
-
} = require("@buoy-gg/storage");
|
|
987
|
-
const counts = storageEventStore.getSubscriberCounts();
|
|
988
|
-
sources.push({
|
|
989
|
-
sourceId: "storage",
|
|
990
|
-
counts
|
|
991
|
-
});
|
|
992
|
-
totalSubscribers += counts.total;
|
|
993
|
-
} catch {
|
|
994
|
-
// Package not installed
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
// Try to get counts from network store
|
|
998
|
-
try {
|
|
999
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
1000
|
-
const {
|
|
1001
|
-
networkEventStore
|
|
1002
|
-
} = require("@buoy-gg/network");
|
|
1003
|
-
const counts = networkEventStore.getSubscriberCounts();
|
|
1004
|
-
sources.push({
|
|
1005
|
-
sourceId: "network",
|
|
1006
|
-
counts
|
|
1007
|
-
});
|
|
1008
|
-
totalSubscribers += counts.total;
|
|
1009
|
-
} catch {
|
|
1010
|
-
// Package not installed
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// Try to get counts from route events store
|
|
1014
|
-
try {
|
|
1015
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
1016
|
-
const {
|
|
1017
|
-
routeEventStore
|
|
1018
|
-
} = require("@buoy-gg/route-events");
|
|
1019
|
-
const counts = routeEventStore.getSubscriberCounts();
|
|
1020
|
-
sources.push({
|
|
1021
|
-
sourceId: "route-events",
|
|
1022
|
-
counts
|
|
1023
|
-
});
|
|
1024
|
-
totalSubscribers += counts.total;
|
|
1025
|
-
} catch {
|
|
1026
|
-
// Package not installed
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
// Try to get counts from render tracker (highlight-updates)
|
|
1030
|
-
try {
|
|
1031
|
-
// @ts-ignore - Dynamic import that may not exist
|
|
1032
|
-
const {
|
|
1033
|
-
RenderTracker,
|
|
1034
|
-
HighlightUpdatesController
|
|
1035
|
-
} = require("@buoy-gg/highlight-updates");
|
|
1036
|
-
const callbackCount = RenderTracker.getRenderEventCallbackCount();
|
|
1037
|
-
// Also count the visual highlight tool as a subscriber when enabled
|
|
1038
|
-
const visualToolEnabled = HighlightUpdatesController?.isEnabled?.() ? 1 : 0;
|
|
1039
|
-
const counts = {
|
|
1040
|
-
eventCallbacks: callbackCount,
|
|
1041
|
-
arrayListeners: visualToolEnabled,
|
|
1042
|
-
total: callbackCount + visualToolEnabled
|
|
1043
|
-
};
|
|
1044
|
-
sources.push({
|
|
1045
|
-
sourceId: "render",
|
|
1046
|
-
counts
|
|
1047
|
-
});
|
|
1048
|
-
totalSubscribers += counts.total;
|
|
1049
|
-
} catch {
|
|
1050
|
-
// Package not installed
|
|
1051
|
-
}
|
|
1052
|
-
return {
|
|
1053
|
-
sources,
|
|
1054
|
-
totalSubscribers
|
|
1055
|
-
};
|
|
1056
|
-
}
|
|
1057
|
-
//# sourceMappingURL=autoDiscoverEventSources.js.map
|
|
1
|
+
"use strict";import{loadToolModule as l,getToolModuleVersion as f}from"@buoy-gg/shared-ui/utils";let b=0;function d(r){return`${r}-${Date.now()}-${++b}`}function v(){try{const{storageEventStore:r}=l("@buoy-gg/storage");return{id:"storage",name:"Storage",eventSources:["storage-async","storage-mmkv"],available:true,subscribe:e=>{return r.onEvent(t=>{const n=t?.data;if(n?.initialScan)return;const s=k(t);e(s)})}}}catch{return null}}function k(r){const e=r;const t=e.storageType==="async"?"storage-async":"storage-mmkv";let n=e.action;if(e.storageType==="async"){const a={setItem:"Set Item",removeItem:"Remove Item",mergeItem:"Merge Item",clear:"Clear All",multiSet:"Multi Set",multiRemove:"Multi Remove",multiMerge:"Multi Merge"};n=a[e.action]||e.action}let s="";if(e.storageType==="async"){switch(e.action){case"setItem":case"removeItem":case"mergeItem":s=e.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{const a=e.data?.pairs?.length||0;s=`${a} key${a!==1?"s":""}`;break}case"multiRemove":{const a=e.data?.keys?.length||0;s=`${a} key${a!==1?"s":""}`;break}case"clear":s="all keys";break}}else{s=e.data?.key||e.data?.instanceId||"unknown"}let o="neutral";if(e.action.includes("set")||e.action.includes("Set")||e.action.includes("merge")||e.action.includes("Merge")){o="success"}return{id:d(t),source:t,timestamp:e.timestamp.getTime(),title:n,subtitle:s,status:o,originalEvent:r}}function S(){try{const{reduxActionStore:r}=l("@buoy-gg/redux");let e=null;return{id:"redux",name:"Redux",eventSources:["redux"],available:true,subscribe:t=>{return r.subscribe(n=>{if(n.length>0){const s=n[0];if(s.id!==e){e=s.id;const o=E(s);t(o)}}})}}}catch{return null}}function E(r){const e=r;let t="neutral";switch(e.category){case"fulfilled":t="success";break;case"rejected":t="error";break;case"pending":t="pending";break;default:t=e.hasStateChange?"success":"neutral"}let n="";if(e.payloadPreview){n=e.payloadPreview}else if(e.hasStateChange&&e.diffSummary){n=e.diffSummary}else if(e.duration!==void 0){n=`${e.duration.toFixed(1)}ms`}else{n=e.sliceName||""}return{id:d("redux"),source:"redux",timestamp:e.timestamp,title:e.type,subtitle:n,status:t,originalEvent:r}}function w(){try{const{networkEventStore:r,networkListener:e,addNetworkListener:t}=l("@buoy-gg/network");const n=new Map;return{id:"network",name:"Network",eventSources:["network"],available:true,setup:()=>{const s=e();if(!s.isActive){s.startListening()}if(s.listenerCount===0){t(o=>{r.processNetworkEvent(o)})}},subscribe:s=>{const o=Date.now();return r.onEvent(a=>{const u=a;const i=n.get(u.id);if(!i){if(typeof u.timestamp==="number"&&u.timestamp<o){return}const c=m(a);n.set(u.id,c.id);s(c)}else{const c=m(a);c.id=i;s(c)}},false)}}}catch{return null}}function m(r){const e=r;let t="neutral";if(e.status===void 0){t="pending"}else if(e.error||e.status>=400){t="error"}else if(e.status>=200&&e.status<400){t="success"}const n=e.operationName||`${e.method} ${e.path||e.url}`;const s=[];if(e.status!==void 0){s.push(`${e.status}`)}else if(e.error){s.push("Error")}else{s.push("Pending")}if(e.duration!==void 0){s.push(`${e.duration.toFixed(0)}ms`)}if(e.host){s.push(e.host)}return{id:d("network"),source:"network",timestamp:e.timestamp,title:n,subtitle:s.join(" \xB7 "),status:t,originalEvent:r}}function C(){try{const{reactQueryEventStore:r}=l("@buoy-gg/react-query");let e=null;return{id:"react-query",name:"React Query",eventSources:["react-query","react-query-query","react-query-mutation"],available:true,subscribe:t=>{let n=true;const s=new Set;const o=a=>a.queryHash??(a.mutationId!==void 0?`m-${a.mutationId}`:null);return r.subscribe(a=>{if(n){n=false;if(a.length>0){e=a[0].id}return}if(a.length>0){const u=a[0];if(u.id!==e){e=u.id;const i=u.type??"";const c=o(u);if(i==="query-fetch-start"||i==="mutation-start"){if(c)s.add(c)}else if(i==="query-fetch-success"||i==="query-fetch-error"||i==="mutation-success"||i==="mutation-error"){if(c&&!s.has(c)){return}}const p=q(u);t(p)}}})}}}catch{return null}}function h(r){if(!r||r.length===0)return"unknown";return r.map(e=>{if(typeof e==="string")return e;if(typeof e==="number")return String(e);if(typeof e==="object"&&e!==null){const t=e;const n=Object.values(t)[0];if(typeof n==="string"||typeof n==="number"){return String(n)}return JSON.stringify(e).slice(0,20)}return String(e)}).join(" \u203A ")}function q(r){const e=r;const t=e.type.startsWith("mutation-");const n=t?"react-query-mutation":"react-query-query";let s="neutral";switch(e.type){case"query-fetch-start":case"mutation-start":s="pending";break;case"query-fetch-success":case"mutation-success":s="success";break;case"query-fetch-error":case"mutation-error":s="error";break}let o="";if(e.queryKey){o=h(e.queryKey)}else if(e.mutationKey){o=h(e.mutationKey)}else if(e.mutationId!==void 0){o=`Mutation #${e.mutationId}`}else{o=e.type.replace(/-/g," ")}const a=[];switch(e.type){case"query-fetch-start":a.push("Fetching");break;case"query-fetch-success":a.push("Success");break;case"query-fetch-error":a.push("Error");break;case"query-invalidated":a.push("Invalidated");break;case"mutation-start":a.push("Mutating");break;case"mutation-success":a.push("Success");break;case"mutation-error":a.push("Error");break}if(e.duration!==void 0){a.push(`${e.duration.toFixed(0)}ms`)}let u;if(e.queryHash){u=`rq-query-${e.queryHash}`}else if(e.mutationId!==void 0){u=`rq-mutation-${e.mutationId}`}let i=1;switch(e.type){case"query-fetch-start":case"mutation-start":i=1;break;case"query-fetch-success":case"query-fetch-error":case"mutation-success":case"mutation-error":i=2;break;case"query-invalidated":i=3;break}return{id:d(n),source:n,timestamp:e.timestamp,title:o,subtitle:a.join(" \xB7 "),status:s,originalEvent:r,correlationId:u,sequenceInGroup:i}}function I(){try{const{routeEventStore:r}=l("@buoy-gg/route-events");return{id:"route-events",name:"Routes",eventSources:["route"],available:true,subscribe:e=>{return r.onEvent(t=>{const n=$(t);e(n)})}}}catch{return null}}function $(r){const e=r;let t="neutral";if(e.pathname==="/"){t="success"}else if(Object.keys(e.params).length>0){t="success"}const n=[];const s=Object.keys(e.params).length;if(s>0){n.push(`${s} param${s!==1?"s":""}`)}if(e.timeSincePrevious!==void 0&&e.timeSincePrevious>0){if(e.timeSincePrevious<1e3){n.push(`${e.timeSincePrevious}ms`)}else{n.push(`${(e.timeSincePrevious/1e3).toFixed(1)}s`)}}if(e.previousPathname&&e.previousPathname!==e.pathname){n.push(`from ${e.previousPathname}`)}return{id:d("route"),source:"route",timestamp:e.timestamp,title:e.pathname||"/",subtitle:n.join(" \xB7 ")||"navigation",status:t,originalEvent:r}}function x(){try{const{zustandStateStore:r}=l("@buoy-gg/zustand");let e=null;return{id:"zustand",name:"Zustand",eventSources:["zustand"],available:true,subscribe:t=>{return r.subscribe(n=>{if(n.length>0){const s=n[0];if(s.id!==e){e=s.id;const o=R(s);t(o)}}})}}}catch{return null}}function R(r){const e=r;let t="neutral";if(e.isSlowUpdate){t="pending"}else if(e.hasStateChange){t="success"}const n=[];if(e.changedKeys&&e.changedKeys.length>0){const s=e.changedKeys.slice(0,3).join(", ");const o=e.changedKeys.length>3?` +${e.changedKeys.length-3}`:"";n.push(`${s}${o}`)}else if(e.diffSummary){n.push(e.diffSummary)}if(e.duration!==void 0){n.push(`${e.duration.toFixed(1)}ms`)}if(e.category==="replace"){n.push("replace")}return{id:d("zustand"),source:"zustand",timestamp:e.timestamp,title:e.storeName,subtitle:n.join(" \xB7 ")||(e.hasStateChange?"state changed":"no change"),status:t,originalEvent:r}}function j(){try{const{jotaiStateStore:r}=l("@buoy-gg/jotai");let e=null;return{id:"jotai",name:"Jotai",eventSources:["jotai"],available:true,subscribe:t=>{return r.subscribe(n=>{if(n.length>0){const s=n[0];if(s.id!==e){e=s.id;const o=M(s);t(o)}}})}}}catch{return null}}function M(r){const e=r;let t="neutral";if(e.category==="write"&&e.hasValueChange){t="success"}else if(e.category==="read"){t="neutral"}const n=[];if(e.valuePreview){n.push(e.valuePreview)}else if(e.diffSummary){n.push(e.diffSummary)}if(e.category){n.push(e.category)}return{id:d("jotai"),source:"jotai",timestamp:e.timestamp,title:e.atomLabel,subtitle:n.join(" \xB7 ")||(e.hasValueChange?"value changed":"no change"),status:t,originalEvent:r}}function T(){let r;try{r=l("@buoy-gg/highlight-updates")}catch{return null}try{if(!r.RenderTracker||!r.HighlightUpdatesController){return null}const{RenderTracker:e,HighlightUpdatesController:t}=r;return{id:"render",name:"Render",eventSources:["render"],available:true,setup:()=>{if(t){t.enableBackgroundTracking()}},subscribe:n=>{if(t&&!t.isBackgroundTrackingEnabled()){t.enableBackgroundTracking()}const s=e.onRenderEvent((o,a)=>{const u=L(o,a);n(u)});return()=>{s();t.disableBackgroundTracking()}}}}catch{return null}}function L(r,e){const t=r;const n=e;const s=n.componentName||n.displayName||n.viewType;const o=[];const a={mount:"mounted",props:"props changed",state:"state changed",hooks:"hooks changed",context:"context changed",parent:"parent re-rendered",unknown:"re-rendered"};o.push(a[t.cause.type]||t.cause.type);if(t.cause.type==="props"&&t.cause.changedKeys?.length){const i=t.cause.changedKeys.slice(0,3).join(", ");const c=t.cause.changedKeys.length>3?` +${t.cause.changedKeys.length-3}`:"";o.push(`[${i}${c}]`)}if(t.cause.hookChanges?.length){const i=t.cause.hookChanges[0];if(i.description){o.push(i.description)}}o.push(`#${t.renderNumber}`);let u="neutral";switch(t.cause.type){case"mount":u="neutral";break;case"props":case"state":case"hooks":case"context":u="success";break;case"parent":u="pending";break;default:u="neutral"}return{id:d("render"),source:"render",timestamp:t.timestamp,title:s,subtitle:o.join(" \xB7 "),status:u,originalEvent:{event:t,render:n}}}export function autoDiscoverEventSources(){const r=[];const e=new Set;const t=[v,S,w,C,I,x,j,T];for(const n of t){const s=n();if(s&&s.available){r.push(s);s.eventSources.forEach(o=>e.add(o))}}return{sources:r,availableEventSources:e}}export function getSourceDisplayConfig(r){const e={"storage-async":{label:"Storage",color:"#8B5CF6",icon:"server-outline"},"storage-mmkv":{label:"MMKV",color:"#F59E0B",icon:"flash-outline"},redux:{label:"Redux",color:"#3B82F6",icon:"git-branch-outline"},network:{label:"Network",color:"#10B981",icon:"globe-outline"},"react-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-mutation":{label:"Mutation",color:"#F97316",icon:"flash-outline"},route:{label:"Route",color:"#06B6D4",icon:"navigate-outline"},zustand:{label:"Zustand",color:"#764ABC",icon:"cube-outline"},jotai:{label:"Jotai",color:"#14B8A6",icon:"ellipse-outline"},render:{label:"Render",color:"#F472B6",icon:"layers-outline"}};return e[r]||{label:r,color:"#6B7280",icon:"help-outline"}}let g=null;let y=-1;export function getCachedDiscovery(){if(!g||y!==f()){y=f();g=autoDiscoverEventSources()}return g}export function clearDiscoveryCache(){g=null}export function getAggregatedSubscriberCounts(){const r=[];let e=0;try{const{storageEventStore:t}=l("@buoy-gg/storage");const n=t.getSubscriberCounts();r.push({sourceId:"storage",counts:n});e+=n.total}catch{}try{const{networkEventStore:t}=l("@buoy-gg/network");const n=t.getSubscriberCounts();r.push({sourceId:"network",counts:n});e+=n.total}catch{}try{const{routeEventStore:t}=l("@buoy-gg/route-events");const n=t.getSubscriberCounts();r.push({sourceId:"route-events",counts:n});e+=n.total}catch{}try{const{RenderTracker:t,HighlightUpdatesController:n}=l("@buoy-gg/highlight-updates");const s=t.getRenderEventCallbackCount();const o=n?.isEnabled?.()?1:0;const a={eventCallbacks:s,arrayListeners:o,total:s+o};r.push({sourceId:"render",counts:a});e+=a.total}catch{}return{sources:r,totalSubscribers:e}}
|