@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.
@@ -1,6 +1,5 @@
1
1
  import { Root } from "react-dom/client";
2
2
  import { CSSProperties } 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
  *
@@ -32,8 +29,6 @@ type ChatWidgetLauncher = "auto" | "icon" | "pill";
32
29
  * does, and why it is a plain DOM module rather than a stylesheet.
33
30
  */
34
31
  type ChatWidgetTheme = "auto" | "dark" | "light";
35
- //#endregion
36
- //#region src/types.d.ts
37
32
  type WidgetSenderType = "visitor" | "operator" | "system";
38
33
  interface WidgetConfig {
39
34
  brandColor?: string | null;
@@ -145,8 +140,6 @@ interface WidgetErrorEvent {
145
140
  type: "error";
146
141
  }
147
142
  type WidgetServerEvent = WidgetAssistantStatusEvent | WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent | WidgetSupportStateEvent;
148
- //#endregion
149
- //#region src/transport.d.ts
150
143
  interface ChatTransportHandlers {
151
144
  onClose: () => void;
152
145
  onError: (error: Error) => void;
@@ -173,8 +166,21 @@ interface CreateChatTransportOptions {
173
166
  session: WidgetSessionPayload;
174
167
  }
175
168
  type CreateChatTransport = (options: CreateChatTransportOptions) => ChatTransportConnection;
176
- //#endregion
177
- //#region src/chat-widget.d.ts
169
+ /**
170
+ * Where the widget keeps the visitor token that resumes a conversation.
171
+ *
172
+ * Keyed by widget AND by who the token was issued to. One key per widget used
173
+ * to hand the token to whoever opened the widget next on that browser — after
174
+ * a sign-out, or between two people who don't sign in at all — and the server
175
+ * resumed the previous person's thread for them (chat widget session review
176
+ * 2026-10-28, S1). The server now refuses that resume on its own; this keeps
177
+ * each person's token to themselves so a returning visitor still resumes.
178
+ *
179
+ * The identity part is a short hash of the normalised email, so the address
180
+ * itself isn't written into storage keys. It only partitions storage: the
181
+ * server's identity check is the security boundary, not this.
182
+ */
183
+ type VisitorTokenStorage = Pick<Storage, "getItem" | "setItem"> & Partial<Pick<Storage, "removeItem">>;
178
184
  interface ChatWidgetProps {
179
185
  className?: string;
180
186
  createTransport?: CreateChatTransport;
@@ -209,7 +215,12 @@ interface ChatWidgetProps {
209
215
  * `style` to sit beneath the host's own dialogs.
210
216
  */
211
217
  placement?: ChatWidgetPlacement;
212
- storage?: Pick<Storage, "getItem" | "setItem">;
218
+ /**
219
+ * Where the visitor token is kept, per widget and per visitor (see
220
+ * visitor-token-storage.ts). `removeItem` is optional; with it, the
221
+ * pre-0.16 shared token is retired after its first use.
222
+ */
223
+ storage?: VisitorTokenStorage;
213
224
  /**
214
225
  * Inline styles on the widget root. The intended use is overriding palette
215
226
  * tokens — `{ "--clivly-chat-panel": "#0b0f19" }` — which works because
@@ -224,8 +235,6 @@ interface ChatWidgetProps {
224
235
  theme?: ChatWidgetTheme;
225
236
  widgetId: string;
226
237
  }
227
- //#endregion
228
- //#region src/browser-mount.d.ts
229
238
  interface MountChatWidgetOptions$1 extends Omit<ChatWidgetProps, "getSession" | "widgetId"> {
230
239
  container: Element | ShadowRoot;
231
240
  sessionUrl: string;
@@ -250,12 +259,10 @@ interface ScriptMountResult$1 extends ChatWidgetMount$1 {
250
259
  }
251
260
  declare function mountChatWidgetScript$1(script?: HTMLScriptElement): ScriptMountResult$1;
252
261
  declare function autoMountChatWidgetScript$1(script?: HTMLScriptElement | null): ScriptMountResult$1 | null;
253
- //#endregion
254
- //#region src/browser.d.ts
255
262
  export type ChatWidgetMount = ChatWidgetMount$1;
256
263
  export type MountChatWidgetOptions = MountChatWidgetOptions$1;
257
264
  export type ScriptMountResult = ScriptMountResult$1;
258
265
  export declare const mountChatWidget: typeof mountChatWidget$1;
259
266
  export declare const mountChatWidgetScript: typeof mountChatWidgetScript$1;
260
267
  export declare const autoMountChatWidgetScript: typeof autoMountChatWidgetScript$1;
261
- //#endregion
268
+ export {};
@@ -1,6 +1,5 @@
1
1
  import { Root } from "react-dom/client";
2
2
  import { CSSProperties } 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
  *
@@ -32,8 +29,6 @@ type ChatWidgetLauncher = "auto" | "icon" | "pill";
32
29
  * does, and why it is a plain DOM module rather than a stylesheet.
33
30
  */
34
31
  type ChatWidgetTheme = "auto" | "dark" | "light";
35
- //#endregion
36
- //#region src/types.d.ts
37
32
  type WidgetSenderType = "visitor" | "operator" | "system";
38
33
  interface WidgetConfig {
39
34
  brandColor?: string | null;
@@ -145,8 +140,6 @@ interface WidgetErrorEvent {
145
140
  type: "error";
146
141
  }
147
142
  type WidgetServerEvent = WidgetAssistantStatusEvent | WidgetConversationSnapshotEvent | WidgetErrorEvent | WidgetMessageAckEvent | WidgetMessageCreatedEvent | WidgetSessionReadyEvent | WidgetSupportStateEvent;
148
- //#endregion
149
- //#region src/transport.d.ts
150
143
  interface ChatTransportHandlers {
151
144
  onClose: () => void;
152
145
  onError: (error: Error) => void;
@@ -173,8 +166,21 @@ interface CreateChatTransportOptions {
173
166
  session: WidgetSessionPayload;
174
167
  }
175
168
  type CreateChatTransport = (options: CreateChatTransportOptions) => ChatTransportConnection;
176
- //#endregion
177
- //#region src/chat-widget.d.ts
169
+ /**
170
+ * Where the widget keeps the visitor token that resumes a conversation.
171
+ *
172
+ * Keyed by widget AND by who the token was issued to. One key per widget used
173
+ * to hand the token to whoever opened the widget next on that browser — after
174
+ * a sign-out, or between two people who don't sign in at all — and the server
175
+ * resumed the previous person's thread for them (chat widget session review
176
+ * 2026-10-28, S1). The server now refuses that resume on its own; this keeps
177
+ * each person's token to themselves so a returning visitor still resumes.
178
+ *
179
+ * The identity part is a short hash of the normalised email, so the address
180
+ * itself isn't written into storage keys. It only partitions storage: the
181
+ * server's identity check is the security boundary, not this.
182
+ */
183
+ type VisitorTokenStorage = Pick<Storage, "getItem" | "setItem"> & Partial<Pick<Storage, "removeItem">>;
178
184
  interface ChatWidgetProps {
179
185
  className?: string;
180
186
  createTransport?: CreateChatTransport;
@@ -209,7 +215,12 @@ interface ChatWidgetProps {
209
215
  * `style` to sit beneath the host's own dialogs.
210
216
  */
211
217
  placement?: ChatWidgetPlacement;
212
- storage?: Pick<Storage, "getItem" | "setItem">;
218
+ /**
219
+ * Where the visitor token is kept, per widget and per visitor (see
220
+ * visitor-token-storage.ts). `removeItem` is optional; with it, the
221
+ * pre-0.16 shared token is retired after its first use.
222
+ */
223
+ storage?: VisitorTokenStorage;
213
224
  /**
214
225
  * Inline styles on the widget root. The intended use is overriding palette
215
226
  * tokens — `{ "--clivly-chat-panel": "#0b0f19" }` — which works because
@@ -224,8 +235,6 @@ interface ChatWidgetProps {
224
235
  theme?: ChatWidgetTheme;
225
236
  widgetId: string;
226
237
  }
227
- //#endregion
228
- //#region src/browser-mount.d.ts
229
238
  interface MountChatWidgetOptions$1 extends Omit<ChatWidgetProps, "getSession" | "widgetId"> {
230
239
  container: Element | ShadowRoot;
231
240
  sessionUrl: string;
@@ -250,12 +259,10 @@ interface ScriptMountResult$1 extends ChatWidgetMount$1 {
250
259
  }
251
260
  declare function mountChatWidgetScript$1(script?: HTMLScriptElement): ScriptMountResult$1;
252
261
  declare function autoMountChatWidgetScript$1(script?: HTMLScriptElement | null): ScriptMountResult$1 | null;
253
- //#endregion
254
- //#region src/browser.d.ts
255
262
  export type ChatWidgetMount = ChatWidgetMount$1;
256
263
  export type MountChatWidgetOptions = MountChatWidgetOptions$1;
257
264
  export type ScriptMountResult = ScriptMountResult$1;
258
265
  export declare const mountChatWidget: typeof mountChatWidget$1;
259
266
  export declare const mountChatWidgetScript: typeof mountChatWidgetScript$1;
260
267
  export declare const autoMountChatWidgetScript: typeof autoMountChatWidgetScript$1;
261
- //#endregion
268
+ export {};