@buoy-gg/events 7.0.41 → 7.0.43

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