@clivly/chat-widget 0.3.0-next.6
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 +123 -0
- package/dist/browser-mount.cjs +630 -0
- package/dist/browser-mount.d.cts +129 -0
- package/dist/browser-mount.d.mts +129 -0
- package/dist/browser-mount.mjs +627 -0
- package/dist/browser.cjs +636 -0
- package/dist/browser.d.cts +136 -0
- package/dist/browser.d.mts +136 -0
- package/dist/browser.mjs +633 -0
- package/dist/index.cjs +718 -0
- package/dist/index.d.cts +198 -0
- package/dist/index.d.mts +198 -0
- package/dist/index.mjs +705 -0
- package/dist/widget.global.js +407 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# `@clivly/chat-widget`
|
|
2
|
+
|
|
3
|
+
Embeddable chat widget package for Clivly conversations.
|
|
4
|
+
|
|
5
|
+
This package currently exposes four stable entrypoints with different intended
|
|
6
|
+
use cases.
|
|
7
|
+
|
|
8
|
+
## Entrypoints
|
|
9
|
+
|
|
10
|
+
### `@clivly/chat-widget`
|
|
11
|
+
|
|
12
|
+
Use the package root for app-side integration code.
|
|
13
|
+
|
|
14
|
+
It exports:
|
|
15
|
+
|
|
16
|
+
- React widget components
|
|
17
|
+
- `createSessionFetcher()`
|
|
18
|
+
- `createClivlyTransport()`
|
|
19
|
+
- side-effect-free mount helpers
|
|
20
|
+
|
|
21
|
+
Example:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import {
|
|
25
|
+
createSessionFetcher,
|
|
26
|
+
createClivlyTransport,
|
|
27
|
+
mountChatWidget,
|
|
28
|
+
} from "@clivly/chat-widget";
|
|
29
|
+
|
|
30
|
+
const getSession = createSessionFetcher({
|
|
31
|
+
sessionUrl: "/api/clivly/chat/session",
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `@clivly/chat-widget/browser`
|
|
36
|
+
|
|
37
|
+
Use this entry for the browser auto-mount module build.
|
|
38
|
+
|
|
39
|
+
This entry:
|
|
40
|
+
|
|
41
|
+
- exports `mountChatWidget()`
|
|
42
|
+
- exports `mountChatWidgetScript()`
|
|
43
|
+
- exports `autoMountChatWidgetScript()`
|
|
44
|
+
- auto-mounts at module evaluation time when `document` exists
|
|
45
|
+
|
|
46
|
+
This is the module-side equivalent of the script-tag embed behavior.
|
|
47
|
+
|
|
48
|
+
### `@clivly/chat-widget/mount`
|
|
49
|
+
|
|
50
|
+
Use this entry when you want the mount helpers without the browser entry's
|
|
51
|
+
auto-mount side effect.
|
|
52
|
+
|
|
53
|
+
This is the safest browser/helper entry for host-controlled mounting.
|
|
54
|
+
|
|
55
|
+
It exports:
|
|
56
|
+
|
|
57
|
+
- `mountChatWidget()`
|
|
58
|
+
- `mountChatWidgetScript()`
|
|
59
|
+
- `autoMountChatWidgetScript()`
|
|
60
|
+
- `MountChatWidgetOptions`
|
|
61
|
+
- `ScriptMountResult`
|
|
62
|
+
|
|
63
|
+
### `@clivly/chat-widget/script`
|
|
64
|
+
|
|
65
|
+
This entry maps to the generated global/browser artifact:
|
|
66
|
+
|
|
67
|
+
- `dist/widget.global.js`
|
|
68
|
+
|
|
69
|
+
Use it for script-tag delivery, CDN-style consumption, or any future server path
|
|
70
|
+
that serves the bundled widget directly.
|
|
71
|
+
|
|
72
|
+
## Session bootstrap shape
|
|
73
|
+
|
|
74
|
+
The widget expects a session bootstrap endpoint that returns a
|
|
75
|
+
`WidgetSessionPayload`.
|
|
76
|
+
|
|
77
|
+
Important fields include:
|
|
78
|
+
|
|
79
|
+
- `token`
|
|
80
|
+
- `visitorToken`
|
|
81
|
+
- `conversation`
|
|
82
|
+
- `contact`
|
|
83
|
+
- `messages`
|
|
84
|
+
- optional `socketUrl`
|
|
85
|
+
|
|
86
|
+
When `socketUrl` is present, the widget prefers it over reconstructing the
|
|
87
|
+
socket URL from a client-side template.
|
|
88
|
+
|
|
89
|
+
## Transport behavior
|
|
90
|
+
|
|
91
|
+
The package includes:
|
|
92
|
+
|
|
93
|
+
- `createClivlyTransport()` for real Clivly backends
|
|
94
|
+
- `createWebSocketTransport()` for explicit socket wiring
|
|
95
|
+
- `createLoopbackTransport()` for local UI/testing flows
|
|
96
|
+
|
|
97
|
+
The default browser mount behavior is:
|
|
98
|
+
|
|
99
|
+
1. use a caller-provided `createTransport` when present
|
|
100
|
+
2. otherwise prefer `session.socketUrl`
|
|
101
|
+
3. otherwise fall back to `socketUrlTemplate` when provided
|
|
102
|
+
|
|
103
|
+
## Build outputs
|
|
104
|
+
|
|
105
|
+
The package currently produces:
|
|
106
|
+
|
|
107
|
+
- `dist/index.*`
|
|
108
|
+
- `dist/browser.*`
|
|
109
|
+
- `dist/browser-mount.*`
|
|
110
|
+
- `dist/widget.global.js`
|
|
111
|
+
|
|
112
|
+
The `browser` and `browser-mount` outputs are built as standalone entrypoints.
|
|
113
|
+
|
|
114
|
+
## Host-side pairing
|
|
115
|
+
|
|
116
|
+
The intended host-side SDK helper lives in `@clivly/sdk`:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { createChatSessionHandler } from "@clivly/sdk";
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
That handler is the expected bridge between a host backend holding
|
|
123
|
+
`CLIVLY_API_KEY` and the widget's `sessionUrl`.
|