@dsrcjs/ai-widget 1.0.5 → 1.0.7
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 +37 -40
- package/dist/ai-dana-chat.js +56 -56
- package/dist/echarts-3nlHlFS7.js +18 -0
- package/dist/i18n.d.ts +1 -0
- package/dist/index-ve2JSWl1.js +19 -0
- package/dist/index.js +1 -1
- package/dist/{markdown-impl-Cu_bBFxI.js → markdown-impl-DeMW_FqG.js} +1 -1
- package/dist/{stream-entry-CNdFWIwY.js → stream-entry-Cqex_Oyn.js} +1 -1
- package/package.json +2 -2
- package/dist/echarts-B6eiFnZN.js +0 -18
- package/dist/index-D2Riqtpn.js +0 -19
package/README.md
CHANGED
|
@@ -21,43 +21,40 @@ modifying, reverse-engineering and redistributing it are not.
|
|
|
21
21
|
|
|
22
22
|
### `<script>` tag
|
|
23
23
|
|
|
24
|
-
One tag, no build step.
|
|
25
|
-
reaches your page within minutes
|
|
24
|
+
One tag, no build step. `@1` always carries the current release of the major version: each release clears the
|
|
25
|
+
jsDelivr cache, so it reaches your page within minutes, nothing to bump on your side:
|
|
26
26
|
|
|
27
27
|
```html
|
|
28
|
-
<script src="https://
|
|
29
|
-
<ai-dana-chat
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/@dsrcjs/ai-widget@1/dist/ai-dana-chat.js" defer></script>
|
|
29
|
+
<ai-dana-chat launcher></ai-dana-chat>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Want to pin a version instead? The same file by exact version never changes and is cached forever:
|
|
33
33
|
|
|
34
34
|
```html
|
|
35
|
-
<script src="https://
|
|
35
|
+
<script src="https://cdn.jsdelivr.net/npm/@dsrcjs/ai-widget@1.0.7/dist/ai-dana-chat.js" defer></script>
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Do not put `integrity="…"` (SRI) on the rolling address: the hash is tied to the bytes of one release, and the next
|
|
39
39
|
one would stop your page loading the widget. Pin a version if you need SRI.
|
|
40
40
|
|
|
41
|
-
The
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`api-url` is required on any page that is not the backend itself: the published bundle has no backend address
|
|
45
|
-
baked in, and without the attribute the widget calls the page's own origin. No key: the backend answers such a
|
|
41
|
+
The backend address `https://dev-ai.kgd.gov.kz` is built into the published bundle, so no `api-url` is needed;
|
|
42
|
+
pass one only to use another backend. No key: the backend answers such a
|
|
46
43
|
visitor as the **anonymous tier** (the shared daily budget,
|
|
47
44
|
the default modes and theme, `Access-Control-Allow-Origin: *`, so any site may embed it). A site that asked for its
|
|
48
45
|
own branding, origins and higher limits gets a key and adds `site-key="…"` (see [Site key](#site-key)) from the ready snippet
|
|
49
46
|
AI-Dana gives with the key.
|
|
50
47
|
|
|
51
|
-
| Attribute | Meaning
|
|
52
|
-
| ------------------- |
|
|
53
|
-
| `site-key` | Public key of the widget site; without it the anonymous tier
|
|
54
|
-
| `api-url` | Backend origin
|
|
55
|
-
| `launcher` | Launcher button + floating window. Without it only the window is rendered (size the element yourself)
|
|
56
|
-
| `lang` | `kk` \| `ru` \| `en` (observed)
|
|
57
|
-
| `theme` | `light` \| `dark` \| `auto` (observed)
|
|
58
|
-
| `position` | `bottom-right` (default) \| `bottom-left`
|
|
59
|
-
| `draggable="false"` | Pin the launcher
|
|
60
|
-
| `open` | Open on load
|
|
48
|
+
| Attribute | Meaning |
|
|
49
|
+
| ------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `site-key` | Public key of the widget site; without it the anonymous tier |
|
|
51
|
+
| `api-url` | Backend origin, an absolute `http(s)` URL; absent — the built-in `https://dev-ai.kgd.gov.kz`, `""` — the page's own origin |
|
|
52
|
+
| `launcher` | Launcher button + floating window. Without it only the window is rendered (size the element yourself) |
|
|
53
|
+
| `lang` | `kk` \| `ru` \| `en` (observed) |
|
|
54
|
+
| `theme` | `light` \| `dark` \| `auto` (observed) |
|
|
55
|
+
| `position` | `bottom-right` (default) \| `bottom-left` |
|
|
56
|
+
| `draggable="false"` | Pin the launcher |
|
|
57
|
+
| `open` | Open on load |
|
|
61
58
|
|
|
62
59
|
The element has `open()`, `close()`, `setTheme(theme)` and `setLang(lang)` and fires `openchange`
|
|
63
60
|
(`event.detail.open`). The script also exposes the global `AiDanaChat` with `mountLauncher` and `mount`.
|
|
@@ -80,17 +77,17 @@ const inline = mount(document.getElementById('chat')!, { siteKey: 'YOUR_SITE_KEY
|
|
|
80
77
|
|
|
81
78
|
### Options
|
|
82
79
|
|
|
83
|
-
| Option | Type | Default
|
|
84
|
-
| -------------- | --------------------------------- |
|
|
85
|
-
| `siteKey` | `string` | — (anonymous tier)
|
|
86
|
-
| `apiUrl` | `string` | `
|
|
87
|
-
| `lang` | `'kk' \| 'ru' \| 'en'` | `<html lang>` → browser language → `ru`
|
|
88
|
-
| `theme` | `ThemeOptions` | `{}`
|
|
89
|
-
| `position` | `'bottom-right' \| 'bottom-left'` | `'bottom-right'`
|
|
90
|
-
| `draggable` | `boolean` | `true`
|
|
91
|
-
| `defaultOpen` | `boolean` | `false` (`true` for `mount`)
|
|
92
|
-
| `onOpenChange` | `(open: boolean) => void` | —
|
|
93
|
-
| `visitorId` | `string` (UUID) | kept in `localStorage.aid_visitor`
|
|
80
|
+
| Option | Type | Default | Notes |
|
|
81
|
+
| -------------- | --------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
82
|
+
| `siteKey` | `string` | — (anonymous tier) | Only for sites that were given a key |
|
|
83
|
+
| `apiUrl` | `string` | `https://dev-ai.kgd.gov.kz` (built in) | Backend origin; calls go to `{apiUrl}/api/v1/widget/…`; `''` = same origin |
|
|
84
|
+
| `lang` | `'kk' \| 'ru' \| 'en'` | `<html lang>` → browser language → `ru` | |
|
|
85
|
+
| `theme` | `ThemeOptions` | `{}` | Layer 2, see [Theming](#theming) |
|
|
86
|
+
| `position` | `'bottom-right' \| 'bottom-left'` | `'bottom-right'` | Launcher corner |
|
|
87
|
+
| `draggable` | `boolean` | `true` | Never draggable below 640px |
|
|
88
|
+
| `defaultOpen` | `boolean` | `false` (`true` for `mount`) | |
|
|
89
|
+
| `onOpenChange` | `(open: boolean) => void` | — | |
|
|
90
|
+
| `visitorId` | `string` (UUID) | kept in `localStorage.aid_visitor` | Deprecated: the backend now issues and signs the visitor id itself; a passed id works only while the backend still accepts unsigned ids |
|
|
94
91
|
|
|
95
92
|
### Handle
|
|
96
93
|
|
|
@@ -153,7 +150,7 @@ interface ThemeOptions {
|
|
|
153
150
|
}
|
|
154
151
|
```
|
|
155
152
|
|
|
156
|
-
Dana is one drawn character with no colour options; `logoUrl` replaces her in the header only. Her pictures are
|
|
153
|
+
Dana is one drawn character with no colour options; `logoUrl` (https, a path on your own site or a `data:image/…` URL; sent without a Referer) replaces her in the header only. Her pictures are
|
|
157
154
|
fetched from the backend (`<apiUrl>/static/avatars/dana/`). Site CSS can still style the box around her through
|
|
158
155
|
`::part(avatar)`.
|
|
159
156
|
|
|
@@ -242,14 +239,14 @@ these are one list: the widget is tested to draw every part named here and to na
|
|
|
242
239
|
|
|
243
240
|
## Storage
|
|
244
241
|
|
|
245
|
-
| `localStorage` key | Value
|
|
246
|
-
| ------------------ |
|
|
247
|
-
| `aid_visitor` |
|
|
248
|
-
| `aid_pos` | Dragged launcher offset `{x, y}` from its corner
|
|
249
|
-
| `aid_mode` | Last selected mode slug
|
|
250
|
-
| `aid_prefs` | Visitor's settings `{lang, scheme}`
|
|
251
|
-
| `aid_sidebar` | `collapsed` / `expanded`
|
|
252
|
-
| `aid_intro_ack` | `1` once the intro notice was acknowledged
|
|
242
|
+
| `localStorage` key | Value |
|
|
243
|
+
| ------------------ | ------------------------------------------------------- |
|
|
244
|
+
| `aid_visitor` | Visitor id signed by the backend (`<uuid>:<signature>`) |
|
|
245
|
+
| `aid_pos` | Dragged launcher offset `{x, y}` from its corner |
|
|
246
|
+
| `aid_mode` | Last selected mode slug |
|
|
247
|
+
| `aid_prefs` | Visitor's settings `{lang, scheme}` |
|
|
248
|
+
| `aid_sidebar` | `collapsed` / `expanded` |
|
|
249
|
+
| `aid_intro_ack` | `1` once the intro notice was acknowledged |
|
|
253
250
|
|
|
254
251
|
No cookies are used. With blocked storage (sandboxed iframe, strict private mode) the widget works with a per-load
|
|
255
252
|
visitor and forgets the position.
|