@clivly/chat-widget 0.16.0 → 0.17.1

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.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Root } from "react-dom/client";
2
2
  import { CSSProperties, ReactElement } from "react";
3
- //#region src/layout.d.ts
4
3
  /**
5
4
  * Where the widget sits on the host page, and what its launcher looks like.
6
5
  *
@@ -20,8 +19,6 @@ type ChatWidgetPlacement = "bottom-left" | "bottom-right" | "inline";
20
19
  * The label stays the button's accessible name in every variant.
21
20
  */
22
21
  type ChatWidgetLauncher = "auto" | "icon" | "pill";
23
- //#endregion
24
- //#region src/theme.d.ts
25
22
  /**
26
23
  * Theme resolution for the widget.
27
24
  *
@@ -46,8 +43,6 @@ interface ResolveThemeOptions {
46
43
  * the majority of pages.
47
44
  */
48
45
  export declare function resolveTheme(theme: ChatWidgetTheme, { root, view }?: ResolveThemeOptions): ResolvedTheme;
49
- //#endregion
50
- //#region src/types.d.ts
51
46
  type WidgetSenderType = "visitor" | "operator" | "system";
52
47
  interface WidgetConfig {
53
48
  brandColor?: string | null;
@@ -164,8 +159,6 @@ interface WidgetErrorEvent {
164
159
  type: "error";
165
160
  }
166
161
  type WidgetServerEvent = WidgetAssistantStatusEvent | WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent | WidgetSupportStateEvent;
167
- //#endregion
168
- //#region src/transport.d.ts
169
162
  interface ChatTransportHandlers {
170
163
  onClose: () => void;
171
164
  onError: (error: Error) => void;
@@ -204,8 +197,21 @@ interface CreateLoopbackTransportOptions {
204
197
  replyDelayMs?: number;
205
198
  }
206
199
  export declare function createLoopbackTransport({ operatorName, operatorReply, replyDelayMs }?: CreateLoopbackTransportOptions): CreateChatTransport;
207
- //#endregion
208
- //#region src/chat-widget.d.ts
200
+ /**
201
+ * Where the widget keeps the visitor token that resumes a conversation.
202
+ *
203
+ * Keyed by widget AND by who the token was issued to. One key per widget used
204
+ * to hand the token to whoever opened the widget next on that browser — after
205
+ * a sign-out, or between two people who don't sign in at all — and the server
206
+ * resumed the previous person's thread for them (chat widget session review
207
+ * 2026-10-28, S1). The server now refuses that resume on its own; this keeps
208
+ * each person's token to themselves so a returning visitor still resumes.
209
+ *
210
+ * The identity part is a short hash of the normalised email, so the address
211
+ * itself isn't written into storage keys. It only partitions storage: the
212
+ * server's identity check is the security boundary, not this.
213
+ */
214
+ type VisitorTokenStorage = Pick<Storage, "getItem" | "setItem"> & Partial<Pick<Storage, "removeItem">>;
209
215
  interface ChatWidgetProps {
210
216
  className?: string;
211
217
  createTransport?: CreateChatTransport;
@@ -240,7 +246,12 @@ interface ChatWidgetProps {
240
246
  * `style` to sit beneath the host's own dialogs.
241
247
  */
242
248
  placement?: ChatWidgetPlacement;
243
- storage?: Pick<Storage, "getItem" | "setItem">;
249
+ /**
250
+ * Where the visitor token is kept, per widget and per visitor (see
251
+ * visitor-token-storage.ts). `removeItem` is optional; with it, the
252
+ * pre-0.16 shared token is retired after its first use.
253
+ */
254
+ storage?: VisitorTokenStorage;
244
255
  /**
245
256
  * Inline styles on the widget root. The intended use is overriding palette
246
257
  * tokens — `{ "--clivly-chat-panel": "#0b0f19" }` — which works because
@@ -261,8 +272,6 @@ export declare function ChatPanel(): null;
261
272
  export declare function MessageComposer(): null;
262
273
  export declare function PreChatForm(): null;
263
274
  export declare function ConversationView(): null;
264
- //#endregion
265
- //#region src/browser-mount.d.ts
266
275
  interface MountChatWidgetOptions$1 extends Omit<ChatWidgetProps, "getSession" | "widgetId"> {
267
276
  container: Element | ShadowRoot;
268
277
  sessionUrl: string;
@@ -287,8 +296,6 @@ interface ScriptMountResult$1 extends ChatWidgetMount$1 {
287
296
  }
288
297
  declare function mountChatWidgetScript$1(script?: HTMLScriptElement): ScriptMountResult$1;
289
298
  declare function autoMountChatWidgetScript$1(script?: HTMLScriptElement | null): ScriptMountResult$1 | null;
290
- //#endregion
291
- //#region src/clivly-transport.d.ts
292
299
  interface CreateClivlyTransportOptions$1 {
293
300
  createSocket?: (url: string, protocols?: string | string[]) => WebSocket;
294
301
  }
@@ -300,15 +307,11 @@ interface CreateClivlyTransportOptions$1 {
300
307
  * produce a silently dead socket.
301
308
  */
302
309
  declare function createClivlyTransport$1(options?: CreateClivlyTransportOptions$1): CreateChatTransport;
303
- //#endregion
304
- //#region src/session.d.ts
305
310
  interface CreateSessionFetcherOptions {
306
311
  fetchImpl?: typeof fetch;
307
312
  sessionUrl: string;
308
313
  }
309
314
  export declare function createSessionFetcher({ fetchImpl, sessionUrl }: CreateSessionFetcherOptions): GetSession;
310
- //#endregion
311
- //#region src/index.d.ts
312
315
  export type ChatWidgetMount = ChatWidgetMount$1;
313
316
  export type MountChatWidgetOptions = MountChatWidgetOptions$1;
314
317
  export type ScriptMountResult = ScriptMountResult$1;
@@ -317,5 +320,4 @@ export type CreateClivlyTransportOptions = CreateClivlyTransportOptions$1;
317
320
  export declare const createClivlyTransport: typeof createClivlyTransport$1;
318
321
  export declare const mountChatWidget: typeof mountChatWidget$1;
319
322
  export declare const mountChatWidgetScript: typeof mountChatWidgetScript$1;
320
- //#endregion
321
323
  export type { ChatTransportConnection, ChatTransportHandlers, ChatWidgetLauncher, ChatWidgetPlacement, ChatWidgetProps, ChatWidgetTheme, ChatWidgetVisitor, CreateChatTransport, CreateChatTransportOptions, CreateLoopbackTransportOptions, CreateWebSocketTransportOptions, GetSession, GetSessionOptions, ResolvedTheme, WidgetAssistantStatusEvent, WidgetClientCreateMessageEvent, WidgetClientEvent, WidgetClientReadEvent, WidgetClientTopicEvent, WidgetConfig, WidgetContact, WidgetConversation, WidgetConversationSnapshotEvent, WidgetErrorEvent, WidgetMessage, WidgetMessageAckEvent, WidgetMessageCreatedEvent, WidgetSenderType, WidgetServerEvent, WidgetSessionPayload, WidgetSessionReadyEvent, WidgetSummary, WidgetSupport, WidgetSupportState, WidgetSupportStateEvent, WidgetSupportTopic };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Root } from "react-dom/client";
2
2
  import { CSSProperties, ReactElement } from "react";
3
- //#region src/layout.d.ts
4
3
  /**
5
4
  * Where the widget sits on the host page, and what its launcher looks like.
6
5
  *
@@ -20,8 +19,6 @@ type ChatWidgetPlacement = "bottom-left" | "bottom-right" | "inline";
20
19
  * The label stays the button's accessible name in every variant.
21
20
  */
22
21
  type ChatWidgetLauncher = "auto" | "icon" | "pill";
23
- //#endregion
24
- //#region src/theme.d.ts
25
22
  /**
26
23
  * Theme resolution for the widget.
27
24
  *
@@ -46,8 +43,6 @@ interface ResolveThemeOptions {
46
43
  * the majority of pages.
47
44
  */
48
45
  export declare function resolveTheme(theme: ChatWidgetTheme, { root, view }?: ResolveThemeOptions): ResolvedTheme;
49
- //#endregion
50
- //#region src/types.d.ts
51
46
  type WidgetSenderType = "visitor" | "operator" | "system";
52
47
  interface WidgetConfig {
53
48
  brandColor?: string | null;
@@ -164,8 +159,6 @@ interface WidgetErrorEvent {
164
159
  type: "error";
165
160
  }
166
161
  type WidgetServerEvent = WidgetAssistantStatusEvent | WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent | WidgetSupportStateEvent;
167
- //#endregion
168
- //#region src/transport.d.ts
169
162
  interface ChatTransportHandlers {
170
163
  onClose: () => void;
171
164
  onError: (error: Error) => void;
@@ -204,8 +197,21 @@ interface CreateLoopbackTransportOptions {
204
197
  replyDelayMs?: number;
205
198
  }
206
199
  export declare function createLoopbackTransport({ operatorName, operatorReply, replyDelayMs }?: CreateLoopbackTransportOptions): CreateChatTransport;
207
- //#endregion
208
- //#region src/chat-widget.d.ts
200
+ /**
201
+ * Where the widget keeps the visitor token that resumes a conversation.
202
+ *
203
+ * Keyed by widget AND by who the token was issued to. One key per widget used
204
+ * to hand the token to whoever opened the widget next on that browser — after
205
+ * a sign-out, or between two people who don't sign in at all — and the server
206
+ * resumed the previous person's thread for them (chat widget session review
207
+ * 2026-10-28, S1). The server now refuses that resume on its own; this keeps
208
+ * each person's token to themselves so a returning visitor still resumes.
209
+ *
210
+ * The identity part is a short hash of the normalised email, so the address
211
+ * itself isn't written into storage keys. It only partitions storage: the
212
+ * server's identity check is the security boundary, not this.
213
+ */
214
+ type VisitorTokenStorage = Pick<Storage, "getItem" | "setItem"> & Partial<Pick<Storage, "removeItem">>;
209
215
  interface ChatWidgetProps {
210
216
  className?: string;
211
217
  createTransport?: CreateChatTransport;
@@ -240,7 +246,12 @@ interface ChatWidgetProps {
240
246
  * `style` to sit beneath the host's own dialogs.
241
247
  */
242
248
  placement?: ChatWidgetPlacement;
243
- storage?: Pick<Storage, "getItem" | "setItem">;
249
+ /**
250
+ * Where the visitor token is kept, per widget and per visitor (see
251
+ * visitor-token-storage.ts). `removeItem` is optional; with it, the
252
+ * pre-0.16 shared token is retired after its first use.
253
+ */
254
+ storage?: VisitorTokenStorage;
244
255
  /**
245
256
  * Inline styles on the widget root. The intended use is overriding palette
246
257
  * tokens — `{ "--clivly-chat-panel": "#0b0f19" }` — which works because
@@ -261,8 +272,6 @@ export declare function ChatPanel(): null;
261
272
  export declare function MessageComposer(): null;
262
273
  export declare function PreChatForm(): null;
263
274
  export declare function ConversationView(): null;
264
- //#endregion
265
- //#region src/browser-mount.d.ts
266
275
  interface MountChatWidgetOptions$1 extends Omit<ChatWidgetProps, "getSession" | "widgetId"> {
267
276
  container: Element | ShadowRoot;
268
277
  sessionUrl: string;
@@ -287,8 +296,6 @@ interface ScriptMountResult$1 extends ChatWidgetMount$1 {
287
296
  }
288
297
  declare function mountChatWidgetScript$1(script?: HTMLScriptElement): ScriptMountResult$1;
289
298
  declare function autoMountChatWidgetScript$1(script?: HTMLScriptElement | null): ScriptMountResult$1 | null;
290
- //#endregion
291
- //#region src/clivly-transport.d.ts
292
299
  interface CreateClivlyTransportOptions$1 {
293
300
  createSocket?: (url: string, protocols?: string | string[]) => WebSocket;
294
301
  }
@@ -300,15 +307,11 @@ interface CreateClivlyTransportOptions$1 {
300
307
  * produce a silently dead socket.
301
308
  */
302
309
  declare function createClivlyTransport$1(options?: CreateClivlyTransportOptions$1): CreateChatTransport;
303
- //#endregion
304
- //#region src/session.d.ts
305
310
  interface CreateSessionFetcherOptions {
306
311
  fetchImpl?: typeof fetch;
307
312
  sessionUrl: string;
308
313
  }
309
314
  export declare function createSessionFetcher({ fetchImpl, sessionUrl }: CreateSessionFetcherOptions): GetSession;
310
- //#endregion
311
- //#region src/index.d.ts
312
315
  export type ChatWidgetMount = ChatWidgetMount$1;
313
316
  export type MountChatWidgetOptions = MountChatWidgetOptions$1;
314
317
  export type ScriptMountResult = ScriptMountResult$1;
@@ -317,5 +320,4 @@ export type CreateClivlyTransportOptions = CreateClivlyTransportOptions$1;
317
320
  export declare const createClivlyTransport: typeof createClivlyTransport$1;
318
321
  export declare const mountChatWidget: typeof mountChatWidget$1;
319
322
  export declare const mountChatWidgetScript: typeof mountChatWidgetScript$1;
320
- //#endregion
321
323
  export type { ChatTransportConnection, ChatTransportHandlers, ChatWidgetLauncher, ChatWidgetPlacement, ChatWidgetProps, ChatWidgetTheme, ChatWidgetVisitor, CreateChatTransport, CreateChatTransportOptions, CreateLoopbackTransportOptions, CreateWebSocketTransportOptions, GetSession, GetSessionOptions, ResolvedTheme, WidgetAssistantStatusEvent, WidgetClientCreateMessageEvent, WidgetClientEvent, WidgetClientReadEvent, WidgetClientTopicEvent, WidgetConfig, WidgetContact, WidgetConversation, WidgetConversationSnapshotEvent, WidgetErrorEvent, WidgetMessage, WidgetMessageAckEvent, WidgetMessageCreatedEvent, WidgetSenderType, WidgetServerEvent, WidgetSessionPayload, WidgetSessionReadyEvent, WidgetSummary, WidgetSupport, WidgetSupportState, WidgetSupportStateEvent, WidgetSupportTopic };