@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,354 +1 @@
1
- "use strict";
2
-
3
- import { approxJsonSize, isJsonSerializable, isOverWireBudget } from "@buoy-gg/shared-ui";
4
- import { unifiedEventStore } from "../stores/unifiedEventStore";
5
- import { generateExport } from "../utils/eventExportFormatter";
6
- import { DEFAULT_COPY_SETTINGS, COPY_PRESETS } from "../types/copySettings";
7
- // ==========================================================================
8
- // Snapshot compaction — keep the device→broker socket healthy.
9
- //
10
- // Each UnifiedEvent carries `originalEvent` (full network bodies, query
11
- // payloads, redux prev/next state trees) for the on-device detail view. The
12
- // sync snapshot re-sends ALL events on every change (throttled to 200ms), and
13
- // measured sessions hit 4–6MB per push — a socket firehose that starves the
14
- // broker and the device's JS thread. Cap the per-event payload for the WIRE
15
- // only; the on-device modal reads the store directly and keeps full detail.
16
- // ==========================================================================
17
-
18
- /** Max serialized bytes of one event's originalEvent on the wire. */
19
- const MAX_SYNC_ORIGINAL_EVENT_BYTES = 16 * 1024;
20
- function truncatedMarker(approxBytes, note) {
21
- return {
22
- __buoyTruncated: true,
23
- approxBytes,
24
- note: note ?? `Payload (≥${(approxBytes / 1024).toFixed(0)}KB approx) exceeds the ${MAX_SYNC_ORIGINAL_EVENT_BYTES / 1024}KB sync limit and stayed on the device. Open the tool on-device (or use the source tool's detail action) for the full payload.`
25
- };
26
- }
27
-
28
- /** Marker replacing per-event redux state trees at the sync boundary. */
29
- const STATE_TREE_OMITTED = {
30
- __buoyOmitted: "state-tree",
31
- note: "prevState/nextState stay on the device (use get_redux_state / the on-device tool)."
32
- };
33
-
34
- /** Marker replacing oversized / unserializable react-query payloads. */
35
- const QUERY_PAYLOAD_OMITTED = {
36
- __buoyOmitted: "query-payload",
37
- note: "Query/mutation data stays on the device (open the Query tool or the on-device Events detail)."
38
- };
39
- const NETWORK_BODY_OMITTED = {
40
- __buoyOmitted: "network-body",
41
- note: "Request/response body stays on the device (open the Network tool or the on-device Events detail)."
42
- };
43
- const NETWORK_HEADERS_OMITTED = {
44
- __buoyOmitted: "network-headers",
45
- note: "Request/response headers stay on the device (open the Network tool or the on-device Events detail)."
46
- };
47
- const GRAPHQL_VARS_OMITTED = {
48
- __buoyOmitted: "graphql-variables",
49
- note: "GraphQL variables stay on the device (open the Network tool or the on-device Events detail)."
50
- };
51
- const STORAGE_VALUE_OMITTED = {
52
- __buoyOmitted: "storage-value",
53
- note: "Storage value stays on the device (open the Storage tool or the on-device Events detail)."
54
- };
55
- const ROUTE_PARAMS_OMITTED = {
56
- __buoyOmitted: "route-params",
57
- note: "Navigation params stay on the device (open the Routes tool or the on-device Events detail)."
58
- };
59
- function isReactQuerySource(source) {
60
- return source === "react-query" || source === "react-query-query" || source === "react-query-mutation";
61
- }
62
-
63
- /**
64
- * Markers are CLONED per field rather than shared. Not for correctness any
65
- * more — sharing a reference is now handled properly below — but because a
66
- * repeated reference makes the size walk report `sawRepeat`, which costs a
67
- * full serializability check on an event we already know is fine.
68
- */
69
- function omitIfHeavy(value, marker) {
70
- if (value === undefined) return undefined;
71
- return isOverWireBudget(value, MAX_SYNC_ORIGINAL_EVENT_BYTES) ? {
72
- ...marker
73
- } : value;
74
- }
75
- function wireQueryPayload(value) {
76
- return omitIfHeavy(value, QUERY_PAYLOAD_OMITTED);
77
- }
78
- function wireError(value) {
79
- if (value == null) return value;
80
- if (value instanceof Error) {
81
- return {
82
- name: value.name,
83
- message: value.message
84
- };
85
- }
86
- return wireQueryPayload(value);
87
- }
88
-
89
- // Events are immutable once created, so compaction is computed once per event
90
- // object and drops out of the cache when the store evicts the event.
91
- const compactionCache = new WeakMap();
92
- function compactEventForSync(event) {
93
- const original = event.originalEvent;
94
- if (typeof original !== "object" || original === null) return event;
95
- const cached = compactionCache.get(event);
96
- if (cached !== undefined) return cached;
97
- let result = event;
98
-
99
- // Redux events carry the whole ReduxAction, whose prevState/nextState are
100
- // FULL state trees — per event. Never ship (or even size-walk) those:
101
- // drop them unconditionally before estimating, so the rest of the action
102
- // (type/payload/meta/diff) still makes it onto the wire when it fits.
103
- let candidate = original;
104
- if ((event.source === "redux" || event.source === "zustand") && ("prevState" in candidate || "nextState" in candidate)) {
105
- // Clone the sentinel per field. `approxSizeOver` flags a repeated object
106
- // reference as cyclic, and a shared marker would truncate the whole
107
- // originalEvent — dropping type/payload, which is the part we kept.
108
- candidate = {
109
- ...candidate,
110
- prevState: {
111
- ...STATE_TREE_OMITTED
112
- },
113
- nextState: {
114
- ...STATE_TREE_OMITTED
115
- },
116
- ...(event.source === "zustand" && "partial" in candidate ? {
117
- partial: {
118
- ...STATE_TREE_OMITTED
119
- }
120
- } : {})
121
- };
122
- result = {
123
- ...event,
124
- originalEvent: candidate
125
- };
126
- } else if (event.source === "jotai" && ("prevValue" in candidate || "nextValue" in candidate)) {
127
- candidate = {
128
- ...candidate,
129
- prevValue: {
130
- ...STATE_TREE_OMITTED
131
- },
132
- nextValue: {
133
- ...STATE_TREE_OMITTED
134
- }
135
- };
136
- result = {
137
- ...event,
138
- originalEvent: candidate
139
- };
140
- } else if (event.source === "render") {
141
- // Highlight-updates events embed the full TrackedRender (including
142
- // renderHistory) plus the RenderEvent (captured props/state, hookChanges).
143
- // Drop those trees so the timeline keeps title/cause type.
144
- const render = candidate.render;
145
- const nested = candidate.event;
146
- const omitCause = cause => {
147
- if (!cause || typeof cause !== "object") return cause;
148
- const {
149
- hookChanges: _hookChanges,
150
- ...rest
151
- } = cause;
152
- return rest;
153
- };
154
- candidate = {
155
- ...candidate,
156
- render: render ? {
157
- ...render,
158
- renderHistory: undefined,
159
- lastRenderCause: omitCause(render.lastRenderCause)
160
- } : render,
161
- event: nested ? {
162
- ...nested,
163
- capturedProps: undefined,
164
- capturedState: undefined,
165
- cause: omitCause(nested.cause)
166
- } : nested
167
- };
168
- result = {
169
- ...event,
170
- originalEvent: candidate
171
- };
172
- } else if (isReactQuerySource(event.source)) {
173
- // React Query events embed the live Query/Mutation objects (cyclic —
174
- // observers point back at the query) plus full cache `queryData`.
175
- // Walking those either flags cyclic and truncates the WHOLE originalEvent
176
- // (losing type/queryKey/duration) or blows the 16KB cap. Drop the live
177
- // objects unconditionally; keep light fields; replace heavy data.
178
- const {
179
- query: _query,
180
- mutation: _mutation,
181
- ...rest
182
- } = candidate;
183
- candidate = {
184
- ...rest,
185
- queryData: wireQueryPayload(rest.queryData),
186
- mutationData: wireQueryPayload(rest.mutationData),
187
- mutationVariables: wireQueryPayload(rest.mutationVariables),
188
- queryError: wireError(rest.queryError),
189
- mutationError: wireError(rest.mutationError)
190
- };
191
- result = {
192
- ...event,
193
- originalEvent: candidate
194
- };
195
- } else if (event.source === "network") {
196
- // Network events carry request/response bodies. A 20KB body blows the
197
- // 16KB cap and truncates the WHOLE originalEvent — method/url/status
198
- // never reach the dashboard. Strip heavy bodies first (same 16KB
199
- // threshold as the network adapter).
200
- const requestSize = typeof candidate.requestSize === "number" ? candidate.requestSize : undefined;
201
- const responseSize = typeof candidate.responseSize === "number" ? candidate.responseSize : undefined;
202
- candidate = {
203
- ...candidate,
204
- requestData: requestSize !== undefined && requestSize > MAX_SYNC_ORIGINAL_EVENT_BYTES ? {
205
- ...NETWORK_BODY_OMITTED
206
- } : omitIfHeavy(candidate.requestData, NETWORK_BODY_OMITTED),
207
- responseData: responseSize !== undefined && responseSize > MAX_SYNC_ORIGINAL_EVENT_BYTES ? {
208
- ...NETWORK_BODY_OMITTED
209
- } : omitIfHeavy(candidate.responseData, NETWORK_BODY_OMITTED),
210
- graphqlVariables: omitIfHeavy(candidate.graphqlVariables, GRAPHQL_VARS_OMITTED),
211
- requestHeaders: omitIfHeavy(candidate.requestHeaders, NETWORK_HEADERS_OMITTED),
212
- responseHeaders: omitIfHeavy(candidate.responseHeaders, NETWORK_HEADERS_OMITTED)
213
- };
214
- result = {
215
- ...event,
216
- originalEvent: candidate
217
- };
218
- } else if (event.source === "storage-async" || event.source === "storage-mmkv") {
219
- const data = candidate.data;
220
- if (data) {
221
- candidate = {
222
- ...candidate,
223
- data: {
224
- ...data,
225
- value: omitIfHeavy(data.value, STORAGE_VALUE_OMITTED),
226
- prevValue: omitIfHeavy(data.prevValue, STORAGE_VALUE_OMITTED),
227
- pairs: omitIfHeavy(data.pairs, STORAGE_VALUE_OMITTED)
228
- }
229
- };
230
- result = {
231
- ...event,
232
- originalEvent: candidate
233
- };
234
- }
235
- } else if (event.source === "route") {
236
- // Route events embed navigate() params. A fat object (or a 20KB
237
- // stringified payload) blows the 16KB cap and truncates the WHOLE
238
- // originalEvent — pathname never reaches the dashboard.
239
- candidate = {
240
- ...candidate,
241
- params: omitIfHeavy(candidate.params, ROUTE_PARAMS_OMITTED)
242
- };
243
- result = {
244
- ...event,
245
- originalEvent: candidate
246
- };
247
- }
248
- const {
249
- bytes,
250
- sawRepeat,
251
- sawBigInt
252
- } = approxJsonSize(candidate, MAX_SYNC_ORIGINAL_EVENT_BYTES);
253
- if (bytes > MAX_SYNC_ORIGINAL_EVENT_BYTES) {
254
- result = {
255
- ...event,
256
- originalEvent: truncatedMarker(bytes)
257
- };
258
- } else if ((sawRepeat || sawBigInt) && !isJsonSerializable(candidate)) {
259
- // Only a CONFIRMED failure truncates. The walk dedupes by identity to stay
260
- // O(limit), so it cannot distinguish a cycle from ordinary structural
261
- // sharing — and `{ user, currentUser }` pointing at one object is both
262
- // commonplace and perfectly serializable. Treating that as cyclic threw
263
- // away the whole event, type and title included, for a payload that was
264
- // always safe to send.
265
- result = {
266
- ...event,
267
- originalEvent: truncatedMarker(-1, "Payload is not JSON-serializable (cyclic or bigint) and stayed on the device.")
268
- };
269
- }
270
- compactionCache.set(event, result);
271
- return result;
272
- }
273
-
274
- /**
275
- * Sync adapter for the events tool, consumed by @buoy-gg/external-sync's
276
- * `useExternalSync` (structurally matches its ToolSyncAdapter interface so
277
- * this package doesn't need a dependency on it).
278
- *
279
- * This adapter is the "remote consumer" of the unified event store. While a
280
- * dashboard is watching, it requests a SET of event sources (defaulting to all,
281
- * narrowed by the dashboard via `setEnabledSources`). On unwatch it releases
282
- * those requests, so — unlike before — the device stops capturing sources that
283
- * nothing else is watching. Source requests are ref-counted in the store, so
284
- * the on-device EventsModal keeps working when open at the same time.
285
- *
286
- * The snapshot carries the device's available sources so the dashboard can
287
- * render the source filter chips (its own auto-discovery finds nothing — the
288
- * tool packages live on the device).
289
- */
290
- export const eventsSyncAdapter = {
291
- version: 2,
292
- getSnapshot: () => ({
293
- events: unifiedEventStore.getEvents().map(compactEventForSync),
294
- availableSources: Array.from(unifiedEventStore.getAvailableEventSources())
295
- }),
296
- subscribe: onChange => {
297
- // Default to all sources until the dashboard narrows the set via
298
- // setEnabledSources — backward compatible with dashboards that don't send
299
- // it. Uses ensureRemoteSourcesDefault so a setEnabledSources that raced
300
- // ahead of this watch isn't clobbered back to "all".
301
- unifiedEventStore.ensureRemoteSourcesDefault();
302
- const unsubscribe = unifiedEventStore.subscribe(() => onChange());
303
- return () => {
304
- unsubscribe();
305
- // Release this consumer's source subscriptions so the device stops
306
- // capturing sources nothing else is watching (fixes the old leak).
307
- unifiedEventStore.clearRemoteSources();
308
- };
309
- },
310
- actions: {
311
- clearEvents: () => {
312
- unifiedEventStore.clearEvents();
313
- },
314
- /**
315
- * Narrow which sources the device captures for this dashboard, driven by
316
- * the dashboard's source badges. Ref-counted in the store, so disabling a
317
- * source here only stops its capture if no other consumer wants it.
318
- */
319
- setEnabledSources: params => {
320
- const sources = params?.sources ?? [];
321
- unifiedEventStore.setRemoteEnabledSources(sources);
322
- return {
323
- enabledSources: sources
324
- };
325
- },
326
- /**
327
- * Format the captured events using the SAME "Copy Settings" formatter the
328
- * on-device copy button uses — driven by toggles instead of taps. Heavy raw
329
- * payloads (`originalEvent`) stay on the device unless the caller opts in
330
- * (`includeEventData`), so a remote driver (MCP/LLM) gets a compact result
331
- * by default and only pulls more detail when it asks. Returns the formatted
332
- * string + metadata so the caller knows how much was returned.
333
- */
334
- exportEvents: params => {
335
- const p = params ?? {};
336
- const base = p.preset && COPY_PRESETS[p.preset] ? COPY_PRESETS[p.preset] : DEFAULT_COPY_SETTINGS;
337
- const settings = {
338
- ...base,
339
- ...(p.settings ?? {})
340
- };
341
- const all = unifiedEventStore.getEvents(); // newest-first, capped by the store
342
- const limit = typeof p.limit === "number" && p.limit > 0 ? p.limit : all.length;
343
- const events = all.slice(0, limit); // newest N (generateExport re-sorts ascending)
344
- return {
345
- output: generateExport(events, settings),
346
- returned: events.length,
347
- totalAvailable: all.length,
348
- includedData: settings.includeEventData,
349
- format: settings.format
350
- };
351
- }
352
- }
353
- };
354
- //# sourceMappingURL=eventsSyncAdapter.js.map
1
+ "use strict";import{approxJsonSize as q,isJsonSerializable as D,isOverWireBudget as R}from"@buoy-gg/shared-ui";import{unifiedEventStore as u}from"../stores/unifiedEventStore";import{generateExport as A}from"../utils/eventExportFormatter";import{DEFAULT_COPY_SETTINGS as x,COPY_PRESETS as _}from"../types/copySettings";const c=16*1024;function S(e,r){return{__buoyTruncated:true,approxBytes:e,note:r??`Payload (\u2265${(e/1024).toFixed(0)}KB approx) exceeds the ${c/1024}KB sync limit and stayed on the device. Open the tool on-device (or use the source tool's detail action) for the full payload.`}}const d={__buoyOmitted:"state-tree",note:"prevState/nextState stay on the device (use get_redux_state / the on-device tool)."};const V={__buoyOmitted:"query-payload",note:"Query/mutation data stays on the device (open the Query tool or the on-device Events detail)."};const y={__buoyOmitted:"network-body",note:"Request/response body stays on the device (open the Network tool or the on-device Events detail)."};const g={__buoyOmitted:"network-headers",note:"Request/response headers stay on the device (open the Network tool or the on-device Events detail)."};const I={__buoyOmitted:"graphql-variables",note:"GraphQL variables stay on the device (open the Network tool or the on-device Events detail)."};const h={__buoyOmitted:"storage-value",note:"Storage value stays on the device (open the Storage tool or the on-device Events detail)."};const k={__buoyOmitted:"route-params",note:"Navigation params stay on the device (open the Routes tool or the on-device Events detail)."};function w(e){return e==="react-query"||e==="react-query-query"||e==="react-query-mutation"}function a(e,r){if(e===void 0)return void 0;return R(e,c)?{...r}:e}function f(e){return a(e,V)}function b(e){if(e==null)return e;if(e instanceof Error){return{name:e.name,message:e.message}}return f(e)}const v=new WeakMap;function z(e){const r=e.originalEvent;if(typeof r!=="object"||r===null)return e;const l=v.get(e);if(l!==void 0)return l;let o=e;let t=r;if((e.source==="redux"||e.source==="zustand")&&("prevState"in t||"nextState"in t)){t={...t,prevState:{...d},nextState:{...d},...e.source==="zustand"&&"partial"in t?{partial:{...d}}:{}};o={...e,originalEvent:t}}else if(e.source==="jotai"&&("prevValue"in t||"nextValue"in t)){t={...t,prevValue:{...d},nextValue:{...d}};o={...e,originalEvent:t}}else if(e.source==="render"){const n=t.render;const i=t.event;const s=m=>{if(!m||typeof m!=="object")return m;const{hookChanges:M,...O}=m;return O};t={...t,render:n?{...n,renderHistory:void 0,lastRenderCause:s(n.lastRenderCause)}:n,event:i?{...i,capturedProps:void 0,capturedState:void 0,cause:s(i.cause)}:i};o={...e,originalEvent:t}}else if(w(e.source)){const{query:n,mutation:i,...s}=t;t={...s,queryData:f(s.queryData),mutationData:f(s.mutationData),mutationVariables:f(s.mutationVariables),queryError:b(s.queryError),mutationError:b(s.mutationError)};o={...e,originalEvent:t}}else if(e.source==="network"){const n=typeof t.requestSize==="number"?t.requestSize:void 0;const i=typeof t.responseSize==="number"?t.responseSize:void 0;t={...t,requestData:n!==void 0&&n>c?{...y}:a(t.requestData,y),responseData:i!==void 0&&i>c?{...y}:a(t.responseData,y),graphqlVariables:a(t.graphqlVariables,I),requestHeaders:a(t.requestHeaders,g),responseHeaders:a(t.responseHeaders,g)};o={...e,originalEvent:t}}else if(e.source==="storage-async"||e.source==="storage-mmkv"){const n=t.data;if(n){t={...t,data:{...n,value:a(n.value,h),prevValue:a(n.prevValue,h),pairs:a(n.pairs,h)}};o={...e,originalEvent:t}}}else if(e.source==="route"){t={...t,params:a(t.params,k)};o={...e,originalEvent:t}}const{bytes:p,sawRepeat:E,sawBigInt:T}=q(t,c);if(p>c){o={...e,originalEvent:S(p)}}else if((E||T)&&!D(t)){o={...e,originalEvent:S(-1,"Payload is not JSON-serializable (cyclic or bigint) and stayed on the device.")}}v.set(e,o);return o}export const eventsSyncAdapter={version:2,getSnapshot:()=>({events:u.getEvents().map(z),availableSources:Array.from(u.getAvailableEventSources())}),subscribe:e=>{u.ensureRemoteSourcesDefault();const r=u.subscribe(()=>e());return()=>{r();u.clearRemoteSources()}},actions:{clearEvents:()=>{u.clearEvents()},setEnabledSources:e=>{const r=e?.sources??[];u.setRemoteEnabledSources(r);return{enabledSources:r}},exportEvents:e=>{const r=e??{};const l=r.preset&&_[r.preset]?_[r.preset]:x;const o={...l,...r.settings??{}};const t=u.getEvents();const p=typeof r.limit==="number"&&r.limit>0?r.limit:t.length;const E=t.slice(0,p);return{output:A(E,o),returned:E.length,totalAvailable:t.length,includedData:o.includeEventData,format:o.format}}}};
@@ -1,244 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Events Copy Settings Types
5
- *
6
- * Configuration for exporting unified events in various formats.
7
- */
8
-
9
- /**
10
- * Copy settings for event export
11
- */
12
-
13
- /**
14
- * Default copy settings
15
- */
16
- export const DEFAULT_COPY_SETTINGS = {
17
- timestampFormat: "relative",
18
- includeSource: true,
19
- includeStatus: true,
20
- includeTitle: true,
21
- includeSubtitle: true,
22
- includeCorrelation: true,
23
- includeDuration: true,
24
- includeSummaryHeader: true,
25
- includeTotalDuration: true,
26
- includeEventData: false,
27
- dataSizeThreshold: 5,
28
- format: "markdown",
29
- filterMode: "all",
30
- filterSources: [],
31
- // Advanced formatting defaults (optimized for LLM consumption)
32
- compactMode: false,
33
- smartJsonParsing: true,
34
- reduxChangedOnly: true,
35
- showStorageDiff: true,
36
- stripVerboseFields: true
37
- };
38
-
39
- /**
40
- * Preset configurations
41
- */
42
- export const COPY_PRESETS = {
43
- /**
44
- * LLM Flow - Optimized for AI assistants
45
- * Readable markdown with relative timestamps and status icons
46
- */
47
- llm: {
48
- timestampFormat: "relative",
49
- includeSource: true,
50
- includeStatus: true,
51
- includeTitle: true,
52
- includeSubtitle: true,
53
- includeCorrelation: true,
54
- includeDuration: true,
55
- includeSummaryHeader: true,
56
- includeTotalDuration: true,
57
- includeEventData: false,
58
- dataSizeThreshold: 5,
59
- format: "markdown",
60
- filterMode: "all",
61
- filterSources: [],
62
- compactMode: false,
63
- smartJsonParsing: true,
64
- reduxChangedOnly: true,
65
- showStorageDiff: true,
66
- stripVerboseFields: true
67
- },
68
- /**
69
- * Bug Report - Full context with errors emphasized
70
- */
71
- bugReport: {
72
- timestampFormat: "both",
73
- includeSource: true,
74
- includeStatus: true,
75
- includeTitle: true,
76
- includeSubtitle: true,
77
- includeCorrelation: true,
78
- includeDuration: true,
79
- includeSummaryHeader: true,
80
- includeTotalDuration: true,
81
- includeEventData: true,
82
- dataSizeThreshold: 10,
83
- format: "markdown",
84
- filterMode: "all",
85
- filterSources: [],
86
- compactMode: false,
87
- smartJsonParsing: true,
88
- reduxChangedOnly: true,
89
- showStorageDiff: true,
90
- stripVerboseFields: true
91
- },
92
- /**
93
- * JSON Export - Full data for debugging/replay
94
- */
95
- json: {
96
- timestampFormat: "absolute",
97
- includeSource: true,
98
- includeStatus: true,
99
- includeTitle: true,
100
- includeSubtitle: true,
101
- includeCorrelation: true,
102
- includeDuration: true,
103
- includeSummaryHeader: false,
104
- includeTotalDuration: false,
105
- includeEventData: true,
106
- dataSizeThreshold: -1,
107
- format: "json",
108
- filterMode: "all",
109
- filterSources: [],
110
- compactMode: false,
111
- smartJsonParsing: true,
112
- reduxChangedOnly: false,
113
- showStorageDiff: false,
114
- stripVerboseFields: false
115
- },
116
- /**
117
- * Errors Only - Just failed events for quick debugging
118
- */
119
- errors: {
120
- timestampFormat: "relative",
121
- includeSource: true,
122
- includeStatus: true,
123
- includeTitle: true,
124
- includeSubtitle: true,
125
- includeCorrelation: true,
126
- includeDuration: true,
127
- includeSummaryHeader: true,
128
- includeTotalDuration: false,
129
- includeEventData: true,
130
- dataSizeThreshold: 10,
131
- format: "markdown",
132
- filterMode: "errors",
133
- filterSources: [],
134
- compactMode: false,
135
- smartJsonParsing: true,
136
- reduxChangedOnly: true,
137
- showStorageDiff: true,
138
- stripVerboseFields: true
139
- },
140
- /**
141
- * Minimal - Just titles and timestamps
142
- */
143
- minimal: {
144
- timestampFormat: "relative",
145
- includeSource: false,
146
- includeStatus: true,
147
- includeTitle: true,
148
- includeSubtitle: false,
149
- includeCorrelation: false,
150
- includeDuration: false,
151
- includeSummaryHeader: false,
152
- includeTotalDuration: false,
153
- includeEventData: false,
154
- dataSizeThreshold: 1,
155
- format: "plaintext",
156
- filterMode: "all",
157
- filterSources: [],
158
- compactMode: true,
159
- smartJsonParsing: true,
160
- reduxChangedOnly: true,
161
- showStorageDiff: false,
162
- stripVerboseFields: true
163
- },
164
- /**
165
- * Mermaid Diagram - Visual sequence diagram for flow visualization
166
- */
167
- mermaid: {
168
- timestampFormat: "relative",
169
- includeSource: true,
170
- includeStatus: true,
171
- includeTitle: true,
172
- includeSubtitle: false,
173
- includeCorrelation: true,
174
- includeDuration: true,
175
- includeSummaryHeader: false,
176
- includeTotalDuration: false,
177
- includeEventData: false,
178
- dataSizeThreshold: 1,
179
- format: "mermaid",
180
- filterMode: "all",
181
- filterSources: [],
182
- compactMode: false,
183
- smartJsonParsing: true,
184
- reduxChangedOnly: true,
185
- showStorageDiff: true,
186
- stripVerboseFields: true
187
- }
188
- };
189
- /**
190
- * Detect which preset matches current settings
191
- */
192
- export function detectActivePreset(settings) {
193
- for (const [presetName, presetConfig] of Object.entries(COPY_PRESETS)) {
194
- const matches = Object.keys(presetConfig).every(key => {
195
- const settingValue = settings[key];
196
- const presetValue = presetConfig[key];
197
-
198
- // Handle array comparison for filterSources
199
- if (Array.isArray(settingValue) && Array.isArray(presetValue)) {
200
- return settingValue.length === presetValue.length && settingValue.every((v, i) => v === presetValue[i]);
201
- }
202
- return settingValue === presetValue;
203
- });
204
- if (matches) return presetName;
205
- }
206
- return null;
207
- }
208
-
209
- /**
210
- * Preset metadata for UI display
211
- */
212
- export const PRESET_METADATA = {
213
- llm: {
214
- label: "LLM",
215
- description: "AI-ready format",
216
- color: "#10B981" // Green
217
- },
218
- bugReport: {
219
- label: "Bug Report",
220
- description: "Full context",
221
- color: "#EF4444" // Red
222
- },
223
- json: {
224
- label: "JSON",
225
- description: "Machine-readable",
226
- color: "#F59E0B" // Yellow
227
- },
228
- errors: {
229
- label: "Errors",
230
- description: "Failed only",
231
- color: "#EF4444" // Red
232
- },
233
- minimal: {
234
- label: "Minimal",
235
- description: "Quick reference",
236
- color: "#6B7280" // Gray
237
- },
238
- mermaid: {
239
- label: "Diagram",
240
- description: "Visual flow",
241
- color: "#A855F7" // Purple
242
- }
243
- };
244
- //# sourceMappingURL=copySettings.js.map
1
+ "use strict";export const DEFAULT_COPY_SETTINGS={timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:false,dataSizeThreshold:5,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true};export const COPY_PRESETS={llm:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:false,dataSizeThreshold:5,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},bugReport:{timestampFormat:"both",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:true,dataSizeThreshold:10,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},json:{timestampFormat:"absolute",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:true,dataSizeThreshold:-1,format:"json",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:false,showStorageDiff:false,stripVerboseFields:false},errors:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:false,includeEventData:true,dataSizeThreshold:10,format:"markdown",filterMode:"errors",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},minimal:{timestampFormat:"relative",includeSource:false,includeStatus:true,includeTitle:true,includeSubtitle:false,includeCorrelation:false,includeDuration:false,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:false,dataSizeThreshold:1,format:"plaintext",filterMode:"all",filterSources:[],compactMode:true,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:false,stripVerboseFields:true},mermaid:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:false,includeCorrelation:true,includeDuration:true,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:false,dataSizeThreshold:1,format:"mermaid",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true}};export function detectActivePreset(u){for(const[a,r]of Object.entries(COPY_PRESETS)){const i=Object.keys(r).every(l=>{const e=u[l];const t=r[l];if(Array.isArray(e)&&Array.isArray(t)){return e.length===t.length&&e.every((o,n)=>o===t[n])}return e===t});if(i)return a}return null}export const PRESET_METADATA={llm:{label:"LLM",description:"AI-ready format",color:"#10B981"},bugReport:{label:"Bug Report",description:"Full context",color:"#EF4444"},json:{label:"JSON",description:"Machine-readable",color:"#F59E0B"},errors:{label:"Errors",description:"Failed only",color:"#EF4444"},minimal:{label:"Minimal",description:"Quick reference",color:"#6B7280"},mermaid:{label:"Diagram",description:"Visual flow",color:"#A855F7"}};
@@ -1,37 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Unified Events - Type Definitions
5
- *
6
- * Note: Types are defined inline to avoid hard dependencies on tool packages.
7
- */
8
-
9
- /**
10
- * Event source identifiers
11
- */
12
-
13
- /**
14
- * Event status for visual indicators
15
- */
16
-
17
- /**
18
- * Unified event structure for the timeline
19
- */
20
-
21
- /**
22
- * Filter state for the event list
23
- */
24
-
25
- /**
26
- * Source metadata for filter badges
27
- */
28
-
29
- /**
30
- * Event listener callback
31
- */
32
-
33
- /**
34
- * Copy settings exports
35
- */
36
- export * from "./copySettings";
37
- //# sourceMappingURL=index.js.map
1
+ "use strict";export*from"./copySettings";