@buoy-gg/events 7.0.4 → 7.0.5

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.
@@ -29,7 +29,7 @@ import type {
29
29
  // Optional Component Loading
30
30
  // ============================================================================
31
31
 
32
- interface OptionalDetailComponents {
32
+ export interface OptionalDetailComponents {
33
33
  StorageEventDetailContent: ComponentType<{
34
34
  conversation: unknown;
35
35
  selectedEventIndex: number;
@@ -236,6 +236,20 @@ interface UnifiedEventDetailProps {
236
236
  visitNumber?: number;
237
237
  onNavigate?: (pathname: string) => void;
238
238
  }>;
239
+ /**
240
+ * Overrides for the per-tool detail pages this component renders.
241
+ *
242
+ * ⚠️ REQUIRED IN A BUNDLED HOST. They are normally resolved with a runtime
243
+ * `require("@buoy-gg/storage")` and friends, which works under Metro but NOT
244
+ * in a Vite/ESM bundle — there every one of them silently resolves to null and
245
+ * opening an event falls back to the generic key/value renderer instead of
246
+ * that tool's real detail page. Buoy Desktop passes all of them.
247
+ *
248
+ * `NetworkEventDetailViewComponent` / `RouteEventDetailComponent` above are
249
+ * the older single-component form of the same thing and still win if both are
250
+ * supplied.
251
+ */
252
+ detailComponents?: Partial<OptionalDetailComponents>;
239
253
  /** Navigate the host app to a route (route detail "Go to route" action). */
240
254
  onNavigate?: (pathname: string) => void;
241
255
  }
@@ -246,8 +260,17 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
246
260
  NetworkEventDetailViewComponent,
247
261
  networkDetailWrapper,
248
262
  RouteEventDetailComponent,
263
+ detailComponents,
249
264
  onNavigate,
250
265
  }: UnifiedEventDetailProps) {
266
+ /**
267
+ * One resolution point for every per-tool detail page: the `require`-loaded
268
+ * set, overridden by whatever the host injected.
269
+ */
270
+ const resolved = useMemo<OptionalDetailComponents>(
271
+ () => ({ ...optionalComponents, ...detailComponents }),
272
+ [detailComponents]
273
+ );
251
274
  const sourceConfig = SOURCE_CONFIG[event.source];
252
275
  const timestamp = new Date(event.timestamp);
253
276
  // Shared ignored-domain/URL patterns — drives the "Ignore Domain / Ignore URL
@@ -259,12 +282,24 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
259
282
  // For storage events, create a conversation object to use with StorageEventDetailContent
260
283
  const storageConversation = useMemo(() => {
261
284
  if (!isStorageEvent(event.source)) return null;
262
- if (!optionalComponents.StorageEventDetailContent) return null;
285
+ if (!resolved.StorageEventDetailContent) return null;
263
286
 
264
- const originalEvent = event.originalEvent as AsyncStorageEvent & {
287
+ const raw = event.originalEvent as AsyncStorageEvent & {
265
288
  storageType?: "async" | "mmkv";
266
289
  };
267
290
 
291
+ /**
292
+ * `timestamp` is a real `Date` in-process but an ISO STRING once the event
293
+ * has crossed a sync transport, and `StorageEventDetailContent` calls
294
+ * `date.getHours()` on it. `new Date(...)` is idempotent for a Date, so
295
+ * normalising unconditionally costs nothing and covers both. The same
296
+ * reasoning is why `event.timestamp` above is wrapped.
297
+ */
298
+ const originalEvent = {
299
+ ...raw,
300
+ timestamp: new Date(raw.timestamp),
301
+ };
302
+
268
303
  // Create a conversation with a single event for the detail view
269
304
  return {
270
305
  key: originalEvent.data?.key || "unknown",
@@ -275,11 +310,11 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
275
310
  valueType: getValueType(originalEvent.data?.value),
276
311
  storageTypes: new Set([originalEvent.storageType || "async"]) as Set<"async" | "mmkv">,
277
312
  };
278
- }, [event]);
313
+ }, [event, resolved]);
279
314
 
280
315
  // For storage events, use the shared StorageEventDetailContent if available
281
- if (storageConversation && optionalComponents.StorageEventDetailContent) {
282
- const { StorageEventDetailContent } = optionalComponents;
316
+ if (storageConversation && resolved.StorageEventDetailContent) {
317
+ const { StorageEventDetailContent } = resolved;
283
318
  return (
284
319
  <View style={styles.container}>
285
320
  <StorageEventDetailContent
@@ -293,8 +328,8 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
293
328
  }
294
329
 
295
330
  // For Redux events, use the shared ReduxActionDetailContent if available
296
- if (event.source === "redux" && optionalComponents.ReduxActionDetailContent) {
297
- const { ReduxActionDetailContent } = optionalComponents;
331
+ if (event.source === "redux" && resolved.ReduxActionDetailContent) {
332
+ const { ReduxActionDetailContent } = resolved;
298
333
  const reduxAction = event.originalEvent as ReduxAction;
299
334
 
300
335
  return (
@@ -316,7 +351,7 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
316
351
  // "Ignore Domain / Ignore URL Pattern" toggles work, and wrap in the optional
317
352
  // body-resolver provider so large bodies can be fetched on demand.
318
353
  const NetworkDetailView =
319
- NetworkEventDetailViewComponent ?? optionalComponents.NetworkEventDetailView;
354
+ NetworkEventDetailViewComponent ?? resolved.NetworkEventDetailView;
320
355
  if (event.source === "network" && NetworkDetailView) {
321
356
  const networkEvent = event.originalEvent as NetworkEvent;
322
357
  const NetworkWrapper = networkDetailWrapper ?? PassThrough;
@@ -346,8 +381,8 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
346
381
  }
347
382
 
348
383
  // For Zustand events, use the shared ZustandStateDetailContent if available
349
- if (event.source === "zustand" && optionalComponents.ZustandStateDetailContent) {
350
- const { ZustandStateDetailContent } = optionalComponents;
384
+ if (event.source === "zustand" && resolved.ZustandStateDetailContent) {
385
+ const { ZustandStateDetailContent } = resolved;
351
386
  const zustandChange = event.originalEvent;
352
387
 
353
388
  return (
@@ -364,8 +399,8 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
364
399
  }
365
400
 
366
401
  // For Jotai events, use the shared JotaiAtomDetailContent if available
367
- if (event.source === "jotai" && optionalComponents.JotaiAtomDetailContent) {
368
- const { JotaiAtomDetailContent } = optionalComponents;
402
+ if (event.source === "jotai" && resolved.JotaiAtomDetailContent) {
403
+ const { JotaiAtomDetailContent } = resolved;
369
404
  const jotaiChange = event.originalEvent;
370
405
 
371
406
  return (
@@ -382,8 +417,8 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
382
417
  }
383
418
 
384
419
  // For render events, use the RenderDetailView if available
385
- if (event.source === "render" && optionalComponents.RenderDetailView) {
386
- const { RenderDetailView } = optionalComponents;
420
+ if (event.source === "render" && resolved.RenderDetailView) {
421
+ const { RenderDetailView } = resolved;
387
422
  const renderData = event.originalEvent as { render: unknown };
388
423
 
389
424
  return (
@@ -399,7 +434,7 @@ export const UnifiedEventDetail = memo(function UnifiedEventDetail({
399
434
  // Prefer an injected component (desktop), fall back to the dynamically required
400
435
  // one (mobile). onNavigate powers the "Go to route" action.
401
436
  const RouteDetail =
402
- RouteEventDetailComponent ?? optionalComponents.RouteEventDetail;
437
+ RouteEventDetailComponent ?? resolved.RouteEventDetail;
403
438
  if (event.source === "route" && RouteDetail) {
404
439
  return (
405
440
  <View style={styles.container}>
package/src/index.tsx CHANGED
@@ -19,7 +19,11 @@ export { eventsToolPreset, createEventsTool } from "./preset";
19
19
  // MAIN COMPONENT
20
20
  // =============================================================================
21
21
  export { UnifiedEventViewer } from "./components/UnifiedEventViewer";
22
- export { EventsModal } from "./components/EventsModal";
22
+ // `EventsToolView` is the same tool rendered inline (header bar + body)
23
+ // instead of inside a JsModal — for hosts that show tools in a panel.
24
+ export { EventsModal, EventsToolView } from "./components/EventsModal";
25
+ // The per-tool detail pages a bundled host must inject — see UnifiedEventDetail.
26
+ export type { OptionalDetailComponents } from "./components/UnifiedEventDetail";
23
27
 
24
28
  // =============================================================================
25
29
  // EXTERNAL SYNC (Adapter for @buoy-gg/external-sync's useExternalSync)