isometrik-plugin-chat-sdk 1.0.7 → 1.0.8
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/cjs/attachment-preview_22.cjs.entry.js +1 -1
- package/dist/cjs/audio-bubble_4.cjs.entry.js +1 -1
- package/dist/cjs/{chat-assets-c88eaa76.js → chat-assets-ff067e4d.js} +23 -3
- package/dist/cjs/chat-assets-ff067e4d.js.map +1 -0
- package/dist/cjs/chat-tile_3.cjs.entry.js +1 -1
- package/dist/cjs/forward-memebers.cjs.entry.js +1 -1
- package/dist/cjs/login-page_3.cjs.entry.js +10 -10
- package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
- package/dist/cjs/member-add.cjs.entry.js +1 -1
- package/dist/cjs/new-chat-sidebar.cjs.entry.js +1 -1
- package/dist/collection/components/theme-provider.js +9 -9
- package/dist/collection/components/theme-provider.js.map +1 -1
- package/dist/collection/constants/chat-assets.js +22 -2
- package/dist/components/chat-assets.js +22 -2
- package/dist/components/chat-assets.js.map +1 -1
- package/dist/components/theme-provider2.js +9 -9
- package/dist/components/theme-provider2.js.map +1 -1
- package/dist/esm/attachment-preview_22.entry.js +1 -1
- package/dist/esm/audio-bubble_4.entry.js +1 -1
- package/dist/esm/{chat-assets-64245cf9.js → chat-assets-95633770.js} +23 -3
- package/dist/esm/chat-assets-95633770.js.map +1 -0
- package/dist/esm/chat-tile_3.entry.js +1 -1
- package/dist/esm/forward-memebers.entry.js +1 -1
- package/dist/esm/login-page_3.entry.js +10 -10
- package/dist/esm/login-page_3.entry.js.map +1 -1
- package/dist/esm/member-add.entry.js +1 -1
- package/dist/esm/new-chat-sidebar.entry.js +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.css +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
- package/dist/isometrik-webchat/{p-db88e29f.entry.js → p-188b2631.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-7216e380.entry.js → p-4bad6da9.entry.js} +2 -2
- package/dist/isometrik-webchat/p-8c73a5d5.entry.js +2 -0
- package/dist/isometrik-webchat/p-8c73a5d5.entry.js.map +1 -0
- package/dist/isometrik-webchat/{p-87cafbe1.entry.js → p-ab5e1e85.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-ccab7fc4.entry.js → p-b44f0bd1.entry.js} +2 -2
- package/dist/isometrik-webchat/p-d6f0838c.js +2 -0
- package/dist/isometrik-webchat/p-d6f0838c.js.map +1 -0
- package/dist/isometrik-webchat/{p-4e2fc241.entry.js → p-e589ff24.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-7a63e947.entry.js → p-ff8f6bd2.entry.js} +2 -2
- package/dist/types/components/theme-provider.d.ts +2 -3
- package/package.json +2 -53
- package/LICENSE +0 -21
- package/dist/cjs/chat-assets-c88eaa76.js.map +0 -1
- package/dist/esm/chat-assets-64245cf9.js.map +0 -1
- package/dist/isometrik-webchat/p-1ccc5a49.js +0 -2
- package/dist/isometrik-webchat/p-1ccc5a49.js.map +0 -1
- package/dist/isometrik-webchat/p-4a5f6807.entry.js +0 -2
- package/dist/isometrik-webchat/p-4a5f6807.entry.js.map +0 -1
- package/readme.md +0 -428
- /package/dist/isometrik-webchat/{p-db88e29f.entry.js.map → p-188b2631.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-7216e380.entry.js.map → p-4bad6da9.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-87cafbe1.entry.js.map → p-ab5e1e85.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-ccab7fc4.entry.js.map → p-b44f0bd1.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-4e2fc241.entry.js.map → p-e589ff24.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-7a63e947.entry.js.map → p-ff8f6bd2.entry.js.map} +0 -0
package/readme.md
DELETED
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
# Isometrik WebChat SDK
|
|
2
|
-
|
|
3
|
-
Embeddable real-time chat for the web — Stencil web components, Isometrik Chat REST APIs, and MQTT.
|
|
4
|
-
|
|
5
|
-
Use it as an npm package in any host app (vanilla JS, React, Vue, Angular, etc.), or run the local demo while developing the SDK itself.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Table of contents
|
|
10
|
-
|
|
11
|
-
1. [Install](#install)
|
|
12
|
-
2. [Quick start](#quick-start)
|
|
13
|
-
3. [API reference](#api-reference)
|
|
14
|
-
4. [How to implement](#how-to-implement)
|
|
15
|
-
5. [Theming](#theming)
|
|
16
|
-
6. [Architecture](#architecture)
|
|
17
|
-
7. [Local development](#local-development)
|
|
18
|
-
8. [Scripts](#scripts)
|
|
19
|
-
9. [Security](#security)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Install
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm install isometrik-webchat
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Peer runtime: modern browsers with ES modules. Credentials come from **your** Isometrik project / backend — nothing secret is required inside the package for consumers.
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Quick start
|
|
34
|
-
|
|
35
|
-
```html
|
|
36
|
-
<div id="chat-root" style="height: 100vh; width: 100%;"></div>
|
|
37
|
-
|
|
38
|
-
<script type="module">
|
|
39
|
-
import { initializeChat, destroyChat } from 'isometrik-webchat';
|
|
40
|
-
|
|
41
|
-
initializeChat({
|
|
42
|
-
containerId: 'chat-root',
|
|
43
|
-
licenseKey: 'YOUR_LICENSE_KEY',
|
|
44
|
-
appSecret: 'YOUR_APP_SECRET',
|
|
45
|
-
userSecret: 'YOUR_USER_SECRET',
|
|
46
|
-
userToken: 'USER_TOKEN_FROM_BACKEND',
|
|
47
|
-
isometrikUserId: 'USER_ID',
|
|
48
|
-
accountId: 'ACCOUNT_ID',
|
|
49
|
-
projectId: 'PROJECT_ID',
|
|
50
|
-
keysetId: 'KEYSET_ID',
|
|
51
|
-
// optional
|
|
52
|
-
baseUrl: 'https://apis.isometrik.io',
|
|
53
|
-
hostUrl: 'wss://connections.isometrik.io:2053/mqtt',
|
|
54
|
-
defaultTheme: 'light',
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// later, when leaving the page / logging out:
|
|
58
|
-
// destroyChat();
|
|
59
|
-
</script>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
When the ESM bundle is loaded on the page, the same helpers are also available on `window`:
|
|
63
|
-
|
|
64
|
-
- `window.initializeChat`
|
|
65
|
-
- `window.destroyChat`
|
|
66
|
-
- `window.switchChatTheme`
|
|
67
|
-
- `window.applyCustomTheme`
|
|
68
|
-
- `window.toggleTheme`
|
|
69
|
-
- `window.chatSidebarProps`
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## API reference
|
|
74
|
-
|
|
75
|
-
### `initializeChat(props)`
|
|
76
|
-
|
|
77
|
-
Creates `<theme-provider>` + `<web-chat>`, mounts into `containerId` (or `document.body`), connects Chat SDK + MQTT, and loads conversations.
|
|
78
|
-
|
|
79
|
-
| Prop | Required | Description |
|
|
80
|
-
|------|----------|-------------|
|
|
81
|
-
| `licenseKey` | yes | Project license key |
|
|
82
|
-
| `appSecret` | yes | App secret |
|
|
83
|
-
| `userSecret` | yes | User secret |
|
|
84
|
-
| `userToken` | yes | Short-lived token from your backend auth |
|
|
85
|
-
| `isometrikUserId` | yes | Isometrik user id |
|
|
86
|
-
| `accountId` | yes | Account id |
|
|
87
|
-
| `projectId` | yes | Project id |
|
|
88
|
-
| `keysetId` | yes | Keyset id |
|
|
89
|
-
| `baseUrl` | no | REST base (default Isometrik API) |
|
|
90
|
-
| `hostUrl` | no | MQTT WSS URL |
|
|
91
|
-
| `containerId` | no | DOM id to mount into |
|
|
92
|
-
| `defaultTheme` | no | `'light'` \| `'dark'` |
|
|
93
|
-
| `themeUrl` | no | Custom theme CSS URL |
|
|
94
|
-
| `slots` | no | Optional panel HTMLElements (`sidebar`, `profile-page`, `contact-info`, …) |
|
|
95
|
-
| `customParts` | no | Optional CE tags: bubbles, tiles, overlays (`messageBubble`, `forwardDialog`, …) |
|
|
96
|
-
|
|
97
|
-
Returns `{ themeProvider, chatComponent, destroy }` or `null` if required props are missing. Calling again is **idempotent** — it destroys the previous instance first.
|
|
98
|
-
|
|
99
|
-
### `destroyChat()`
|
|
100
|
-
|
|
101
|
-
Tears down MQTT (via component disconnect), removes chat DOM, and cleans empty theme providers.
|
|
102
|
-
|
|
103
|
-
### Theme helpers
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
import { switchChatTheme, applyCustomTheme, toggleTheme } from 'isometrik-webchat';
|
|
107
|
-
|
|
108
|
-
switchChatTheme('dark');
|
|
109
|
-
toggleTheme();
|
|
110
|
-
applyCustomTheme({
|
|
111
|
-
themePath: 'https://example.com/my-chat-theme.css',
|
|
112
|
-
// or:
|
|
113
|
-
// themeObject: { 'chat-primary-color': '#0d7377' },
|
|
114
|
-
});
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Sidebar options
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
import { customChatSidebar } from 'isometrik-webchat';
|
|
121
|
-
// or window.chatSidebarProps
|
|
122
|
-
customChatSidebar({ isChatFilter: true });
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Custom UI (Rounit-first)
|
|
126
|
-
|
|
127
|
-
**Primary:** `customParts` — host custom elements; SDK passes **props + callbacks** (text, status, `metaData`, `onSelect` / `onTap` / `onReply`). Functionality stays in the SDK.
|
|
128
|
-
|
|
129
|
-
**Secondary:** named **slots** — layout panels only (empty state, composer shell, …). No per-row props.
|
|
130
|
-
|
|
131
|
-
**Advanced:** events + methods for headless / fully custom chrome.
|
|
132
|
-
|
|
133
|
-
Full guide: [docs/CUSTOMIZATION.md](./docs/CUSTOMIZATION.md).
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
customElements.define('my-chat-tile', class extends HTMLElement {
|
|
137
|
-
conversation; onSelect; unreadCount; previewText;
|
|
138
|
-
connectedCallback() {
|
|
139
|
-
const c = this.conversation || {};
|
|
140
|
-
this.innerHTML = `<b>${c.conversationTitle}</b> ${c.metaData?.orderId || ''}`;
|
|
141
|
-
this.onclick = () => this.onSelect?.(c.conversationId);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
customElements.define('my-message-bubble', class extends HTMLElement {
|
|
146
|
-
message; isSelf; status; onTap; onReply; onForward; onDelete; onInfo;
|
|
147
|
-
connectedCallback() { this.render(); }
|
|
148
|
-
// SDK / applyCustomPartProps will call render() after prop assigns
|
|
149
|
-
render() {
|
|
150
|
-
const m = this.message || {};
|
|
151
|
-
this.innerHTML = `<div>${m.body || ''} <button data-a="reply">Reply</button></div>`;
|
|
152
|
-
this.querySelector('[data-a=reply]')?.addEventListener('click', () => this.onReply?.(m));
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
initializeChat({
|
|
157
|
-
// …creds
|
|
158
|
-
customParts: {
|
|
159
|
-
chatTile: 'my-chat-tile',
|
|
160
|
-
messageBubble: 'my-message-bubble', // props: message, isSelf, status, onTap, onReply, onForward, onDelete, onInfo
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
#### Slots (layout panels)
|
|
166
|
-
|
|
167
|
-
Leave a slot empty to keep the default Isometrik UI.
|
|
168
|
-
|
|
169
|
-
**Whole regions**
|
|
170
|
-
|
|
171
|
-
| Slot | Replaces |
|
|
172
|
-
|------|----------|
|
|
173
|
-
| `sidebar` | Entire left rail |
|
|
174
|
-
| `header` | Active chat header |
|
|
175
|
-
| `messages` | Message list / body |
|
|
176
|
-
| `composer` | Entire footer |
|
|
177
|
-
| `empty` | No-chat placeholder |
|
|
178
|
-
| `right-panel` | Entire right rail |
|
|
179
|
-
| `boot-loader` | Initial loading screen |
|
|
180
|
-
|
|
181
|
-
**Finer panels** (when parent region slot is empty)
|
|
182
|
-
|
|
183
|
-
| Slot | Replaces |
|
|
184
|
-
|------|----------|
|
|
185
|
-
| `profile-rail` | Left icon rail |
|
|
186
|
-
| `conversation-list` | Chat list |
|
|
187
|
-
| `profile-page` | Own profile tab |
|
|
188
|
-
| `group-cast` | Groupcast tab |
|
|
189
|
-
| `reply-preview` | Reply strip above input |
|
|
190
|
-
| `attachment-preview` | Media attach UI |
|
|
191
|
-
| `composer-input` | Input bar only |
|
|
192
|
-
| `contact-info` | Right contact panel |
|
|
193
|
-
| `profile-info` | Right profile panel |
|
|
194
|
-
| `message-search` | Right search panel |
|
|
195
|
-
|
|
196
|
-
**Overlays** (slot and/or `customParts` tag)
|
|
197
|
-
|
|
198
|
-
| Slot / part | Replaces |
|
|
199
|
-
|-------------|----------|
|
|
200
|
-
| `forward-dialog` / `forwardDialog` | Forward picker (drawer) |
|
|
201
|
-
| `add-member` / `addMember` | Add member dialog (drawer) |
|
|
202
|
-
| `message-info` | Read receipts panel |
|
|
203
|
-
| `media-gallery` / `mediaGallery` | Media lightbox |
|
|
204
|
-
| `context-menu` / `contextMenu` | Right-click menu |
|
|
205
|
-
| `block-list` / `blockList` | Blocked users list |
|
|
206
|
-
| `toast` | Toast notifications |
|
|
207
|
-
|
|
208
|
-
### Public events & methods (headless / advanced)
|
|
209
|
-
|
|
210
|
-
Prefer `customParts` when you only need custom bubbles/tiles. Use events when you paint lists yourself.
|
|
211
|
-
|
|
212
|
-
**Events** (on `<web-chat>` / `chatComponent`)
|
|
213
|
-
|
|
214
|
-
| Event | Detail |
|
|
215
|
-
|-------|--------|
|
|
216
|
-
| `chatReady` | `{ userMetaData, conversations }` — bootstrap done |
|
|
217
|
-
| `conversationsChange` | `{ conversations }` |
|
|
218
|
-
| `messagesChange` | `{ conversationId, messages }` |
|
|
219
|
-
| `conversationSelect` | `{ conversationId, conversation }` |
|
|
220
|
-
| `replyChange` | `{ replyMessage }` |
|
|
221
|
-
| `chatError` | `{ code, message, cause? }` |
|
|
222
|
-
| `unreadMessageCountUpdated` | existing |
|
|
223
|
-
| `conversationNotFound` | existing |
|
|
224
|
-
| `messageReadStatusUpdated` | existing |
|
|
225
|
-
|
|
226
|
-
**Methods**
|
|
227
|
-
|
|
228
|
-
| Method | Purpose |
|
|
229
|
-
|--------|---------|
|
|
230
|
-
| `selectConversation(id \| null)` | Open / clear thread |
|
|
231
|
-
| `sendText(body, conversationId?)` | Send text (uses reply if set) |
|
|
232
|
-
| `sendMedia(files, conversationId?, caption?)` | Send media (presign → upload → post; uses reply if set) |
|
|
233
|
-
| `setReply(message)` / `clearReply()` | Reply target |
|
|
234
|
-
| `loadMoreMessages()` | Older messages |
|
|
235
|
-
| `loadMoreConversations()` | Next conversation page |
|
|
236
|
-
| `getChatState()` | Snapshot |
|
|
237
|
-
|
|
238
|
-
```js
|
|
239
|
-
const { chatComponent } = initializeChat({ /* creds */ });
|
|
240
|
-
|
|
241
|
-
chatComponent.addEventListener('conversationsChange', e => {
|
|
242
|
-
renderMySidebar(e.detail.conversations);
|
|
243
|
-
});
|
|
244
|
-
chatComponent.addEventListener('messagesChange', e => {
|
|
245
|
-
renderMyMessages(e.detail.messages);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// user clicked a row in your UI:
|
|
249
|
-
await chatComponent.selectConversation(conversationId);
|
|
250
|
-
|
|
251
|
-
// user typed in your composer:
|
|
252
|
-
await chatComponent.sendText('hello');
|
|
253
|
-
|
|
254
|
-
// user picked files in your composer:
|
|
255
|
-
await chatComponent.sendMedia(fileInput.files, conversationId, 'optional caption');
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
**Local demo**
|
|
259
|
-
|
|
260
|
-
1. `npm start`
|
|
261
|
-
2. Open [http://localhost:3333/custom-ui-demo.html](http://localhost:3333/custom-ui-demo.html) for the guide, or
|
|
262
|
-
3. [http://localhost:3333/?demoCustomUi=1](http://localhost:3333/?demoCustomUi=1) after login — sample `demo-chat-tile`, `demo-message-bubble`, and custom `empty` slot.
|
|
263
|
-
|
|
264
|
-
Production customization guide: [docs/CUSTOMIZATION.md](./docs/CUSTOMIZATION.md).
|
|
265
|
-
|
|
266
|
-
**Via light DOM:**
|
|
267
|
-
|
|
268
|
-
```html
|
|
269
|
-
<web-chat …>
|
|
270
|
-
<div slot="profile-page">…</div>
|
|
271
|
-
<div slot="contact-info">…</div>
|
|
272
|
-
<div slot="composer">…</div>
|
|
273
|
-
</web-chat>
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## How to implement
|
|
279
|
-
|
|
280
|
-
### 1. Vanilla / any HTML host
|
|
281
|
-
|
|
282
|
-
1. Install the package (or load the ESM bundle from your CDN/build).
|
|
283
|
-
2. Ensure a sized container (`height` + `width`).
|
|
284
|
-
3. After your user authenticates, call `initializeChat` with the token + ids from your backend.
|
|
285
|
-
4. On logout / route leave, call `destroyChat()`.
|
|
286
|
-
|
|
287
|
-
### 2. React / Next.js (client only)
|
|
288
|
-
|
|
289
|
-
Chat must run in the browser (DOM + MQTT). Use a client component:
|
|
290
|
-
|
|
291
|
-
```tsx
|
|
292
|
-
'use client';
|
|
293
|
-
|
|
294
|
-
import { useEffect } from 'react';
|
|
295
|
-
import { initializeChat, destroyChat } from 'isometrik-webchat';
|
|
296
|
-
|
|
297
|
-
export function ChatPanel(props: {
|
|
298
|
-
userToken: string;
|
|
299
|
-
isometrikUserId: string;
|
|
300
|
-
/* …other required creds from env / API */
|
|
301
|
-
}) {
|
|
302
|
-
useEffect(() => {
|
|
303
|
-
initializeChat({
|
|
304
|
-
containerId: 'isometrik-chat',
|
|
305
|
-
...props,
|
|
306
|
-
// licenseKey, appSecret, userSecret, accountId, projectId, keysetId
|
|
307
|
-
});
|
|
308
|
-
return () => destroyChat();
|
|
309
|
-
}, [props.userToken, props.isometrikUserId]);
|
|
310
|
-
|
|
311
|
-
return <div id="isometrik-chat" style={{ height: '100%', width: '100%' }} />;
|
|
312
|
-
}
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Fetch `userToken` from **your** backend; do not put long-lived app secrets in public frontend bundles when you can avoid it.
|
|
316
|
-
|
|
317
|
-
### 3. Vue / Angular / others
|
|
318
|
-
|
|
319
|
-
Same pattern: mount a container element, call `initializeChat` after auth, call `destroyChat` on unmount.
|
|
320
|
-
|
|
321
|
-
### 4. Credentials flow (recommended)
|
|
322
|
-
|
|
323
|
-
```
|
|
324
|
-
Your app login
|
|
325
|
-
→ your backend authenticates user with Isometrik
|
|
326
|
-
→ backend returns userToken + isometrikUserId (+ project ids)
|
|
327
|
-
→ frontend calls initializeChat(...)
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
---
|
|
331
|
-
|
|
332
|
-
## Theming
|
|
333
|
-
|
|
334
|
-
- Default theme CSS can be overridden with `themeUrl` on `initializeChat`.
|
|
335
|
-
- Runtime: `switchChatTheme('dark' | 'light')`, `toggleTheme()`, or `applyCustomTheme({ themePath, themeObject })`.
|
|
336
|
-
- Container should be full size; chat fills 100% of parent width/height.
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## Architecture
|
|
341
|
-
|
|
342
|
-
High-level shape of the SDK:
|
|
343
|
-
|
|
344
|
-
```
|
|
345
|
-
Host app
|
|
346
|
-
└─ initializeChat() / <web-chat>
|
|
347
|
-
├─ bootstrap → device, SDK init, first data load
|
|
348
|
-
├─ mqtt-bridge → realtime events
|
|
349
|
-
├─ navigation → open chat / URL helpers
|
|
350
|
-
├─ conversation-ops → clear, delete, block, message delete
|
|
351
|
-
├─ lib/chat → REST helpers (conversations, messages, session)
|
|
352
|
-
├─ lib/mqtt → session, parse, dispatch
|
|
353
|
-
└─ UI
|
|
354
|
-
├─ smart Stencil components (data + events)
|
|
355
|
-
└─ presentational UI tags (stories / shared)
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
| Layer | Responsibility |
|
|
359
|
-
|-------|----------------|
|
|
360
|
-
| Public API (`initializeChat`) | Mount / unmount, pass credentials |
|
|
361
|
-
| `<web-chat>` shell | Props, state, events, render wiring |
|
|
362
|
-
| `lib/chat` | Fetch conversations, messages, groupcast, session |
|
|
363
|
-
| `lib/mqtt` | Connect, subscribe, parse, dispatch actions to UI state |
|
|
364
|
-
| Smart UI (`ChatUIComponent`) | Sidebar, body, footer, header — talk to stores/APIs |
|
|
365
|
-
| Presentational UI (`stories` / `shared`) | Markup & styling only |
|
|
366
|
-
| `store/` | Unread counts, conversation helpers, group members |
|
|
367
|
-
| `api/` | Focused REST helpers used by shell / smart UI |
|
|
368
|
-
|
|
369
|
-
**Build outputs**
|
|
370
|
-
|
|
371
|
-
| Path | Purpose |
|
|
372
|
-
|------|---------|
|
|
373
|
-
| `src/` | Source of truth |
|
|
374
|
-
| `www/` | Local demo site (`npm start`) — not what you publish |
|
|
375
|
-
| `dist/` | Production package consumers import |
|
|
376
|
-
|
|
377
|
-
**Realtime path**
|
|
378
|
-
|
|
379
|
-
```
|
|
380
|
-
MQTT broker → MqttSession → mqtt-bridge → lib/mqtt/dispatch → state → UI
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
For a deeper folder map while contributing to this repo, see [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md).
|
|
384
|
-
|
|
385
|
-
---
|
|
386
|
-
|
|
387
|
-
## Local development
|
|
388
|
-
|
|
389
|
-
```bash
|
|
390
|
-
yarn install # or npm install
|
|
391
|
-
yarn start # stencil build --dev --watch --serve → www/
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
Local demo credentials live in `src/constants/chat-creds.js` (dev only). Do not ship those in consumer builds.
|
|
395
|
-
|
|
396
|
-
```bash
|
|
397
|
-
yarn build # production dist
|
|
398
|
-
yarn storybook # UI catalog
|
|
399
|
-
yarn test # unit / e2e
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
---
|
|
403
|
-
|
|
404
|
-
## Scripts
|
|
405
|
-
|
|
406
|
-
| Script | Description |
|
|
407
|
-
|--------|-------------|
|
|
408
|
-
| `yarn start` | Dev demo with HMR (`www/`) |
|
|
409
|
-
| `yarn build` | Production `dist/` |
|
|
410
|
-
| `yarn storybook` | Component Storybook |
|
|
411
|
-
| `yarn build-storybook` | Static Storybook build |
|
|
412
|
-
| `yarn test` | Spec + e2e |
|
|
413
|
-
| `yarn generate` | Scaffold a Stencil component |
|
|
414
|
-
|
|
415
|
-
---
|
|
416
|
-
|
|
417
|
-
## Security
|
|
418
|
-
|
|
419
|
-
- Prefer **backend-issued, short-lived** `userToken`.
|
|
420
|
-
- Do not commit or log tokens / MQTT payloads in production.
|
|
421
|
-
- Rotate any secrets that were ever committed in local cred files.
|
|
422
|
-
- Avoid embedding long-lived app secrets in public client bundles when your architecture allows proxying through your backend.
|
|
423
|
-
|
|
424
|
-
---
|
|
425
|
-
|
|
426
|
-
## License
|
|
427
|
-
|
|
428
|
-
MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|