@paramms/chat-widget 1.0.41 → 1.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.
package/README.md CHANGED
@@ -158,12 +158,32 @@ Drop that before `</body>` and you have a working floating bubble — no other J
158
158
  | `data-relay-target` | `el` | CSS selector for an existing element to mount into. Ignored in launcher mode |
159
159
  | `data-relay-height` | `height` | Inline container height. Ignored in launcher mode |
160
160
  | `data-relay-inbox` | `inbox` | `"true"` adds a back-chevron → full conversation list. Requires `data-relay-launcher="false"` — see the note below the table |
161
+ | `data-relay-inbox-start` | `inboxStart` | `"true"` opens **directly on the conversation list** instead of a single thread — for a dedicated "Messages" page. Implies `inbox`. Requires `data-relay-launcher="false"` |
161
162
  | `data-relay-inbox-scope` | `inboxScope` | `tenant` (default) \| `profile` |
163
+ | `data-relay-tenant-id` | `tenantId` | Your business id. Lists threads across **all** your chatrooms without naming one — use instead of `data-relay-app` on an inbox page |
162
164
 
163
165
  **What's NOT available as an attribute:** `user`/`subject` as nested objects, `quickReplies`, `i18n`, and `refreshToken` — an HTML attribute can only hold a string, so these need the JS-object form below. (`launcherMessage`'s two attributes are a workaround for exactly this: the React prop takes one `{ title, subtitle }` object, which an attribute can't express, so it's split into two flat attributes that get recombined.)
164
166
 
165
167
  **`inbox` requires `data-relay-launcher="false"`** — same limit React has (a launcher+inbox combination needs a different component there, `ChatAppLauncher`); with the default floating launcher, `data-relay-inbox` is silently ignored.
166
168
 
169
+ **A whole "Messages" page, zero JavaScript.** `data-relay-inbox` alone only puts the list *behind* a back-chevron — the widget still lands on one thread, which is right for a product page and wrong for a page whose entire job is the inbox. `data-relay-inbox-start` makes the list the landing view, and `data-relay-tenant-id` spans every chatroom you run:
170
+
171
+ ```html
172
+ <div id="relay-inbox" style="height:600px"></div>
173
+
174
+ <script
175
+ async
176
+ src="https://relay.paramms.com/embed.js"
177
+ data-relay-tenant-id="acme"
178
+ data-relay-inbox-start="true"
179
+ data-relay-launcher="false"
180
+ data-relay-target="#relay-inbox"
181
+ data-relay-user="user_123"
182
+ ></script>
183
+ ```
184
+
185
+ Tapping a row opens that conversation against **its own** chatroom; its back-chevron returns to the list. There's no ✕ in this mode — the list is the root view, so there'd be nothing behind it to close to. ✎ compose opens against your default chatroom (the server reports which). This is the script-tag equivalent of React's `<ChatApp tenantId={...} />`.
186
+
167
187
  ### Full config — JS object
168
188
 
169
189
  Same field names, all in one place, same object whether it's set on page load or reacts to something happening later:
@@ -389,6 +409,8 @@ RTL is detected automatically for Arabic, Hebrew, Persian and Urdu browsers.
389
409
  | `i18n` | `I18nStrings` | English | UI string overrides |
390
410
  | `inbox` | `boolean` | `false` | Add a ‹ back in the chatroom header that opens the full `ChatApp` conversation list (inline widgets only) |
391
411
  | `inboxScope` | `'tenant' \| 'profile'` | `'tenant'` | With `inbox`: list threads across all chatrooms (`tenant`) or just this one (`profile`) |
412
+ | `inboxStart` | `boolean` | `false` | Land ON the conversation list instead of a single thread (a dedicated "Messages" page). Implies `inbox`; requires `launcher: false`. Script-tag/embed only — in React use `<ChatApp/>` directly |
413
+ | `tenantId` | `string` | — | Script-tag/embed only. Your business id: lists threads across ALL your chatrooms with no chatroom named. Only meaningful with `inboxStart` — a single thread still needs a `profileId` |
392
414
 
393
415
  ## Development
394
416
 
@@ -43,11 +43,24 @@ export declare class ConnectionManager {
43
43
  * The outbox is bounded so a prolonged outage can't grow memory without limit
44
44
  * — oldest queued frames are dropped past the cap. */
45
45
  send(frame: ClientFrame): void;
46
+ /** How many frames are waiting to go out. Useful for a host that wants to
47
+ * show "message pending" state, and for asserting the outbox stays bounded. */
48
+ pendingCount(): number;
46
49
  close(): void;
47
50
  private handle;
48
51
  private refreshing;
49
52
  private fatal;
53
+ /** Release queued frames. When called from 'opened' we know the canonical
54
+ * conversation id the server just resolved us to, and queued `send` frames
55
+ * are retargeted to it. A manager only ever opens ONE conversation (its
56
+ * `opts.open`), so every queued send belongs to that thread by
57
+ * construction — but the id it was queued with can be STALE (queued against
58
+ * the previous session's conversation before a reconnect). Retargeting is a
59
+ * no-op in the normal case and rescues the message in the stale one. */
50
60
  private flush;
61
+ /** Bounded enqueue — the cap lives here so EVERY path that queues respects
62
+ * it (a failed `raw` used to push straight onto the array, bypassing it). */
63
+ private queue;
51
64
  private raw;
52
65
  private onClosed;
53
66
  }
package/dist/embed.d.ts CHANGED
@@ -130,9 +130,31 @@ export interface RelaySettings {
130
130
  * ✕ in the list view returns to this widget's original single-thread
131
131
  * view. Requires `launcher: false`. */
132
132
  inbox?: boolean;
133
+ /** Open DIRECTLY on the conversation list instead of a single thread —
134
+ * what you want for a dedicated "Messages" page. `inbox: true` alone only
135
+ * adds a back-chevron to a single thread, so the list is reachable but
136
+ * never the landing view; that is the right default for a widget bolted
137
+ * onto a product page, and the wrong one for a page whose whole job is the
138
+ * inbox. Implies `inbox`. Requires `launcher: false` (same restriction as
139
+ * `inbox`), and `profileId` OR `tenantId`.
140
+ *
141
+ * With `inboxStart`, tapping a row opens that conversation and its own
142
+ * back-chevron returns to the list. There is no ✕ — the list IS the root
143
+ * view here, so there is nothing behind it to close back to. */
144
+ inboxStart?: boolean;
133
145
  /** Inbox scope when `inbox` is set: `'tenant'` (default) lists the user's
134
146
  * threads across ALL your chatrooms; `'profile'` limits it to this one. */
135
147
  inboxScope?: 'tenant' | 'profile';
148
+ /** Your business id — lists the visitor's threads across ALL your chatrooms
149
+ * without naming one, and lets "new conversation" open against your default
150
+ * chatroom (the server reports it). This is the vanilla equivalent of
151
+ * React's `<ChatApp tenantId=… />`, which has always accepted a tenant with
152
+ * no profile; the script tag previously could not express that at all and
153
+ * hard-required a `profileId`.
154
+ *
155
+ * Only meaningful with `inboxStart` — a single-thread widget still needs a
156
+ * `profileId`, because a lone thread has to belong to a specific chatroom. */
157
+ tenantId?: string;
136
158
  }
137
159
  export type RelayCommand = 'boot' | 'update' | 'identify' | 'shutdown';
138
160
  /** The public command dispatcher exposed as `window.Relay`. */