@buoy-gg/events 2.1.15 → 3.0.0
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/lib/commonjs/components/EventsCopySettingsView.js.map +1 -0
- package/lib/commonjs/components/EventsModal.js.map +1 -0
- package/lib/commonjs/components/ReactQueryEventDetail.js.map +1 -0
- package/lib/commonjs/components/UnifiedEventDetail.js.map +1 -0
- package/lib/commonjs/components/UnifiedEventFilters.js.map +1 -0
- package/lib/commonjs/components/UnifiedEventItem.js.map +1 -0
- package/lib/commonjs/components/UnifiedEventList.js.map +1 -0
- package/lib/commonjs/components/UnifiedEventViewer.js.map +1 -0
- package/lib/commonjs/hooks/useUnifiedEvents.js.map +1 -0
- package/lib/commonjs/index.js +21 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/preset.js.map +1 -0
- package/lib/commonjs/stores/unifiedEventStore.js +48 -1
- package/lib/commonjs/stores/unifiedEventStore.js.map +1 -0
- package/lib/commonjs/sync/eventsSyncAdapter.js +37 -0
- package/lib/commonjs/sync/eventsSyncAdapter.js.map +1 -0
- package/lib/commonjs/types/copySettings.js.map +1 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/autoDiscoverEventSources.js.map +1 -0
- package/lib/commonjs/utils/badgeSelectionStorage.js.map +1 -0
- package/lib/commonjs/utils/copySettingsStorage.js.map +1 -0
- package/lib/commonjs/utils/correlationUtils.js.map +1 -0
- package/lib/commonjs/utils/eventExportFormatter.js.map +1 -0
- package/lib/commonjs/utils/eventTransformers.js.map +1 -0
- package/lib/module/components/EventsCopySettingsView.js.map +1 -0
- package/lib/module/components/EventsModal.js.map +1 -0
- package/lib/module/components/ReactQueryEventDetail.js.map +1 -0
- package/lib/module/components/UnifiedEventDetail.js.map +1 -0
- package/lib/module/components/UnifiedEventFilters.js.map +1 -0
- package/lib/module/components/UnifiedEventItem.js.map +1 -0
- package/lib/module/components/UnifiedEventList.js.map +1 -0
- package/lib/module/components/UnifiedEventViewer.js.map +1 -0
- package/lib/module/hooks/useUnifiedEvents.js.map +1 -0
- package/lib/module/index.js +9 -1
- package/lib/module/index.js.map +1 -0
- package/lib/module/preset.js.map +1 -0
- package/lib/module/stores/unifiedEventStore.js +48 -1
- package/lib/module/stores/unifiedEventStore.js.map +1 -0
- package/lib/module/sync/eventsSyncAdapter.js +34 -0
- package/lib/module/sync/eventsSyncAdapter.js.map +1 -0
- package/lib/module/types/copySettings.js.map +1 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/autoDiscoverEventSources.js.map +1 -0
- package/lib/module/utils/badgeSelectionStorage.js.map +1 -0
- package/lib/module/utils/copySettingsStorage.js.map +1 -0
- package/lib/module/utils/correlationUtils.js.map +1 -0
- package/lib/module/utils/eventExportFormatter.js.map +1 -0
- package/lib/module/utils/eventTransformers.js.map +1 -0
- package/lib/typescript/components/EventsCopySettingsView.d.ts.map +1 -0
- package/lib/typescript/components/EventsModal.d.ts.map +1 -0
- package/lib/typescript/components/ReactQueryEventDetail.d.ts.map +1 -0
- package/lib/typescript/components/UnifiedEventDetail.d.ts.map +1 -0
- package/lib/typescript/components/UnifiedEventFilters.d.ts.map +1 -0
- package/lib/typescript/components/UnifiedEventItem.d.ts.map +1 -0
- package/lib/typescript/components/UnifiedEventList.d.ts.map +1 -0
- package/lib/typescript/components/UnifiedEventViewer.d.ts.map +1 -0
- package/lib/typescript/hooks/useUnifiedEvents.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/lib/typescript/stores/unifiedEventStore.d.ts +20 -1
- package/lib/typescript/stores/unifiedEventStore.d.ts.map +1 -0
- package/lib/typescript/sync/eventsSyncAdapter.d.ts +23 -0
- package/lib/typescript/sync/eventsSyncAdapter.d.ts.map +1 -0
- package/lib/typescript/types/copySettings.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/utils/autoDiscoverEventSources.d.ts.map +1 -0
- package/lib/typescript/utils/badgeSelectionStorage.d.ts.map +1 -0
- package/lib/typescript/utils/copySettingsStorage.d.ts.map +1 -0
- package/lib/typescript/utils/correlationUtils.d.ts.map +1 -0
- package/lib/typescript/utils/eventExportFormatter.d.ts.map +1 -0
- package/lib/typescript/utils/eventTransformers.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/index.tsx +9 -1
- package/src/stores/unifiedEventStore.ts +48 -1
- package/src/sync/eventsSyncAdapter.ts +31 -0
|
@@ -25,6 +25,8 @@ class UnifiedEventStore {
|
|
|
25
25
|
private events: UnifiedEvent[] = [];
|
|
26
26
|
private listeners: Set<UnifiedEventListener> = new Set();
|
|
27
27
|
private activeSources: Set<EventSource> = new Set();
|
|
28
|
+
private clearListeners: Set<() => void> = new Set();
|
|
29
|
+
private remoteAvailableSources: Set<EventSource> | null = null;
|
|
28
30
|
|
|
29
31
|
// Track which sources are currently subscribed
|
|
30
32
|
private sourceUnsubscribers: Map<string, () => void> = new Map();
|
|
@@ -40,12 +42,50 @@ class UnifiedEventStore {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
|
-
* Get which event source types are available
|
|
45
|
+
* Get which event source types are available. In remote mirror mode this
|
|
46
|
+
* reflects the synced device's availability instead of local discovery.
|
|
44
47
|
*/
|
|
45
48
|
getAvailableEventSources(): Set<EventSource> {
|
|
49
|
+
if (this.remoteAvailableSources) {
|
|
50
|
+
return this.remoteAvailableSources;
|
|
51
|
+
}
|
|
46
52
|
return getCachedDiscovery().availableEventSources;
|
|
47
53
|
}
|
|
48
54
|
|
|
55
|
+
// ===========================================================================
|
|
56
|
+
// REMOTE MIRROR MODE
|
|
57
|
+
// ===========================================================================
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Override source availability with the synced device's (auto-discovery
|
|
61
|
+
* finds nothing on the dashboard — the tool packages live on the device).
|
|
62
|
+
* Pass null to restore local discovery.
|
|
63
|
+
*/
|
|
64
|
+
setRemoteAvailableSources(sources: EventSource[] | null): void {
|
|
65
|
+
this.remoteAvailableSources = sources ? new Set(sources) : null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Replace the entire event list and notify listeners. Used in remote
|
|
70
|
+
* mirror mode where full snapshots arrive from a synced device.
|
|
71
|
+
*/
|
|
72
|
+
replaceEvents(events: UnifiedEvent[]): void {
|
|
73
|
+
this.events = events.slice(0, MAX_EVENTS);
|
|
74
|
+
this.activeSources = new Set(events.map((event) => event.source));
|
|
75
|
+
this.notifyListeners();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Listen for clearEvents() calls. Used in remote mirror mode to forward a
|
|
80
|
+
* clear performed in the dashboard UI to the synced device.
|
|
81
|
+
*/
|
|
82
|
+
onClear(listener: () => void): () => void {
|
|
83
|
+
this.clearListeners.add(listener);
|
|
84
|
+
return () => {
|
|
85
|
+
this.clearListeners.delete(listener);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
49
89
|
/**
|
|
50
90
|
* Subscribe to all available event sources
|
|
51
91
|
*/
|
|
@@ -341,6 +381,13 @@ class UnifiedEventStore {
|
|
|
341
381
|
this.activeSources.clear();
|
|
342
382
|
this.networkEventIdMap.clear();
|
|
343
383
|
this.notifyListeners();
|
|
384
|
+
this.clearListeners.forEach((listener) => {
|
|
385
|
+
try {
|
|
386
|
+
listener();
|
|
387
|
+
} catch {
|
|
388
|
+
// Ignore listener errors
|
|
389
|
+
}
|
|
390
|
+
});
|
|
344
391
|
}
|
|
345
392
|
|
|
346
393
|
/**
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { unifiedEventStore } from "../stores/unifiedEventStore";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sync adapter for the events tool, consumed by @buoy-gg/external-sync's
|
|
5
|
+
* `useExternalSync` (structurally matches its ToolSyncAdapter interface so
|
|
6
|
+
* this package doesn't need a dependency on it).
|
|
7
|
+
*
|
|
8
|
+
* Subscribing starts aggregation from every discovered source, so the
|
|
9
|
+
* unified timeline fills while a dashboard is watching even if the on-device
|
|
10
|
+
* EventsModal was never opened. The snapshot carries the device's available
|
|
11
|
+
* sources so the dashboard can render the source filter chips (its own
|
|
12
|
+
* auto-discovery finds nothing — the tool packages live on the device).
|
|
13
|
+
*/
|
|
14
|
+
export const eventsSyncAdapter = {
|
|
15
|
+
version: 1,
|
|
16
|
+
getSnapshot: () => ({
|
|
17
|
+
events: unifiedEventStore.getEvents(),
|
|
18
|
+
availableSources: Array.from(unifiedEventStore.getAvailableEventSources()),
|
|
19
|
+
}),
|
|
20
|
+
subscribe: (onChange: () => void) => {
|
|
21
|
+
unifiedEventStore.subscribeToAll();
|
|
22
|
+
// Source subscriptions are left in place on unwatch — the on-device
|
|
23
|
+
// EventsModal may also be using them, and aggregation is cheap.
|
|
24
|
+
return unifiedEventStore.subscribe(() => onChange());
|
|
25
|
+
},
|
|
26
|
+
actions: {
|
|
27
|
+
clearEvents: () => {
|
|
28
|
+
unifiedEventStore.clearEvents();
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|