@buoy-gg/events 7.0.41 → 7.0.42

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