@dsrcjs/ai-widget 1.0.6 → 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/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. AI-Dana serves the widget itself, and this address always carries the current release — it
25
- reaches your page within minutes of a release, nothing to bump on your side:
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://ai-dana.example.kz/widget/ai-dana-chat.js" defer></script>
29
- <ai-dana-chat api-url="https://ai-dana.example.kz" launcher></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://ai-dana.example.kz/widget/v/1.2.3/ai-dana-chat.js" defer></script>
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 package is also on npm, and jsDelivr mirrors it (`@1` = the current major, updated within a day or so):
42
- `https://cdn.jsdelivr.net/npm/@dsrcjs/ai-widget@1/dist/ai-dana-chat.js`.
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, an absolute `http(s)` URL (required on other sites); absent or `""` = the page's own 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 | Notes |
84
- | -------------- | --------------------------------- | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
85
- | `siteKey` | `string` | — (anonymous tier) | Only for sites that were given a key |
86
- | `apiUrl` | `string` | `''` (no address in the published build) | Backend origin; calls go to `{apiUrl}/api/v1/widget/…`; `''` = same origin |
87
- | `lang` | `'kk' \| 'ru' \| 'en'` | `<html lang>` → browser language → `ru` | |
88
- | `theme` | `ThemeOptions` | `{}` | Layer 2, see [Theming](#theming) |
89
- | `position` | `'bottom-right' \| 'bottom-left'` | `'bottom-right'` | Launcher corner |
90
- | `draggable` | `boolean` | `true` | Never draggable below 640px |
91
- | `defaultOpen` | `boolean` | `false` (`true` for `mount`) | |
92
- | `onOpenChange` | `(open: boolean) => void` | — | |
93
- | `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 |
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