@helpway/react 0.15.2 → 0.16.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/dist/index.d.ts CHANGED
@@ -111,6 +111,13 @@ interface IdentifyData {
111
111
  name?: string;
112
112
  image?: string;
113
113
  metadata?: Record<string, unknown>;
114
+ /**
115
+ * Move this browser's visitor to the contact above even if it already
116
+ * belongs to a different contact. Dangerous: it merges whatever history
117
+ * this browser has into that contact. Off by default; without it the
118
+ * server keeps the existing link and returns that contact (#193).
119
+ */
120
+ reassign?: boolean;
114
121
  }
115
122
  /** Use a slice of the widget store with auto re-render */
116
123
  declare function useWidgetStore<T>(selector: (state: WidgetStore) => T): T;
@@ -174,6 +181,13 @@ declare function useWidget(): {
174
181
  name?: string;
175
182
  image?: string;
176
183
  metadata?: Record<string, unknown>;
184
+ /**
185
+ * Move this browser's visitor to the contact above even if it already
186
+ * belongs to a different contact. Dangerous: it merges whatever history
187
+ * this browser has into that contact. Off by default; without it the
188
+ * server keeps the existing link and returns that contact (#193).
189
+ */
190
+ reassign?: boolean;
177
191
  }) => Promise<any>;
178
192
  };
179
193
 
@@ -261,6 +275,30 @@ declare function useUnread(): {
261
275
  totalUnread: number;
262
276
  };
263
277
 
278
+ /**
279
+ * How many conversations are waiting on the visitor to reply.
280
+ *
281
+ * Exists because `useUnread()` answers a question consumers usually do not have.
282
+ * A thread we answered two minutes ago and a thread the visitor closed
283
+ * themselves look identical in the widget — same row, same weight, no marker —
284
+ * and that is the moment a support thread dies: we reply, the visitor never
285
+ * registers it, the conversation is abandoned with an unanswered message in it.
286
+ *
287
+ * Counts human replies, not AI ones. An auto-reply follows nearly every visitor
288
+ * message, so including them leaves the indicator permanently lit for anyone who
289
+ * has ever opened the widget, which teaches people to ignore it.
290
+ *
291
+ * Written by hand in a downstream dashboard before it existed here; a
292
+ * `hideLauncher` integration badging its own trigger should not have to
293
+ * reimplement the rule.
294
+ *
295
+ * ```tsx
296
+ * const awaiting = useAwaitingReply();
297
+ * // "3 awaiting reply" — label it, do not just show the number
298
+ * ```
299
+ */
300
+ declare function useAwaitingReply(): number;
301
+
264
302
  /**
265
303
  * Subscribe to raw WebSocket events.
266
304
  * For advanced usage — most apps should use useTimeline/usePresence instead.
@@ -271,6 +309,13 @@ declare function useUnread(): {
271
309
  * if (event.type === 'timelineItemCreated') { ... }
272
310
  * })
273
311
  * ```
312
+ *
313
+ * The subscription lives as long as the socket instance, not as long as the
314
+ * handler's identity (#146). Callers pass inline arrows, which are new on every
315
+ * render; with `handler` in the effect deps that meant `handlers.delete` and
316
+ * `handlers.add` on every render above the caller, and any event that arrived
317
+ * between the two was dropped. The latest handler is kept in a ref and one
318
+ * stable wrapper is subscribed per socket.
274
319
  */
275
320
  declare function useRealtime(handler: (event: RealtimeEvent) => void): void;
276
321
 
@@ -474,6 +519,19 @@ interface AnnouncementPreviewsProps {
474
519
  * so its visual stays byte-identical to the original.
475
520
  */
476
521
  footer?: ReactNode;
522
+ /**
523
+ * How many cards to render before collapsing the rest into a single
524
+ * "+N more updates" row.
525
+ *
526
+ * Unlimited by default, which is what every existing consumer already gets.
527
+ * The launcher passes a real number because the strip above it is shared with
528
+ * the incoming-reply card and the two together ran off the top of the screen:
529
+ * four cards need more than 600px of viewport, and the topmost ones were
530
+ * simply gone. Clipping is a priority statement, not a size fix — a reply is a
531
+ * conversation waiting on the visitor, an announcement is content that can
532
+ * wait, so the announcements are what gets collapsed.
533
+ */
534
+ maxVisible?: number;
477
535
  }
478
536
  /**
479
537
  * `<AnnouncementPreviews>` — proactive "new content" cards shown when
@@ -490,7 +548,7 @@ interface AnnouncementPreviewsProps {
490
548
  *
491
549
  * Must be rendered inside `<SupportProvider>`.
492
550
  */
493
- declare function AnnouncementPreviews({ onOpen, avatar, placement, footer, }: AnnouncementPreviewsProps): react_jsx_runtime.JSX.Element | null;
551
+ declare function AnnouncementPreviews({ onOpen, avatar, placement, footer, maxVisible, }: AnnouncementPreviewsProps): react_jsx_runtime.JSX.Element | null;
494
552
 
495
553
  /**
496
554
  * Lightweight Markdown → HTML renderer.
@@ -520,4 +578,4 @@ declare function MarkdownContent({ bodyHtml, bodyMarkdown, className, }: {
520
578
  className?: string;
521
579
  }): react_jsx_runtime.JSX.Element | null;
522
580
 
523
- export { type AnnouncementPreviewEntry, AnnouncementPreviews, type AnnouncementPreviewsPlacement, type AnnouncementPreviewsProps, Composer, DefaultWidget, type HelpwayPublicAPI, HelpwayWidget, type HelpwayWidgetProps, type IdentifyData, MarkdownContent, MessageBubble, MessageList, MessagePreview, type MessagePreviewPlacement, type MessagePreviewProps, SupportProvider, WidgetLogo, linkifyText, renderMarkdown, useComposer, useConversations, useIdentify, usePresence, useRealtime, useTimeline, useUnread, useWidget, useWidgetStore };
581
+ export { type AnnouncementPreviewEntry, AnnouncementPreviews, type AnnouncementPreviewsPlacement, type AnnouncementPreviewsProps, Composer, DefaultWidget, type HelpwayPublicAPI, HelpwayWidget, type HelpwayWidgetProps, type IdentifyData, MarkdownContent, MessageBubble, MessageList, MessagePreview, type MessagePreviewPlacement, type MessagePreviewProps, SupportProvider, WidgetLogo, linkifyText, renderMarkdown, useAwaitingReply, useComposer, useConversations, useIdentify, usePresence, useRealtime, useTimeline, useUnread, useWidget, useWidgetStore };