@zabbu/chat-widget 0.10.0 → 0.10.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/README.md +90 -0
  3. package/package.json +4 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,146 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
6
+ project adheres to [Semantic Versioning](https://semver.org/). Versions before `0.1.0`
7
+ below were not formally tracked; `0.1.0` is the baseline this file starts from.
8
+
9
+ ## [0.10.1] - 2026-08-26
10
+
11
+ ### Added
12
+ - This changelog now ships with the package (was backfilled through 0.10.0 but hadn't
13
+ been republished yet), and a README exists for the first time — the npm package page
14
+ was blank before this.
15
+
16
+ ## [0.10.0] - 2026-08-26
17
+
18
+ ### Added
19
+ - `window.Zabbu`, a programmatic API (`init`, `open`, `close`, `toggle`, `on`/`off`) for
20
+ host pages that want to control the widget from their own code instead of only through
21
+ data-* attributes read once at auto-init.
22
+ - `primaryColor`, `position`, `welcomeText`, and `colorScheme` overrides — via data-*
23
+ attributes or the `init()` config object — that take precedence over the Site's own
24
+ saved config, so customizing the widget no longer requires portal-web access.
25
+ - `ready`, `open`, `close`, and `message` events via `Zabbu.on()`.
26
+ - Bottom-left placement (`data-position="bottom-left"` / `position: "bottom-left"`) —
27
+ `widgetPosition` was already returned by the public config endpoint but never applied
28
+ by the loader.
29
+
30
+ ### Changed
31
+ - A script tag with no `data-site-key` no longer throws on load — it stays inert until
32
+ something calls `Zabbu.init()`.
33
+
34
+ ## [0.9.2] - 2026-08-26
35
+
36
+ ### Fixed
37
+ - The iframe's own files (`index.html`, `chat-ui.js`/`.css`) now resolve relative to the
38
+ script's actual directory instead of just its origin. On a shared CDN like
39
+ jsDelivr/unpkg, where every package lives under the same domain, resolving by origin
40
+ alone pointed at a file that doesn't exist there.
41
+
42
+ ## [0.9.1] - 2026-08-26
43
+
44
+ ### Fixed
45
+ - Republished pointing at the production backend — the previous publish's `npm run
46
+ build` hook ran without `API_BASE_URL` set and picked up the localhost default
47
+ instead.
48
+
49
+ ## [0.9.0] - 2026-08-25
50
+
51
+ ### Added
52
+ - Per-site shadow style (soft, elevated, brand-glow) and a brand-color glow option for
53
+ the launcher.
54
+ - An unread-message badge on the launcher.
55
+ - A live agent-presence indicator, a CTA-button opening style, a dark color scheme, and
56
+ slash/at-command autocomplete in the chat panel.
57
+
58
+ ### Changed
59
+ - Rebranded from `conex-chat-widget` to `zabbu-chat-widget` — DOM ids, CSS
60
+ classes/custom properties, and the localStorage key prefix.
61
+
62
+ ## [0.8.0] - 2026-08-24
63
+
64
+ ### Added
65
+ - Gradient backgrounds, configurable opening styles, and a proactive teaser bubble.
66
+ - An SVG icon set for the floating launcher button, selectable per site.
67
+
68
+ ## [0.7.0] - 2026-08-22
69
+
70
+ ### Added
71
+ - The loader now notifies the backend once per session (`chat-opened`) when the visitor
72
+ opens the panel, so an event-triggered rule/command can respond proactively — the
73
+ reply arrives as a normal bot message, no typing required.
74
+ - Sound config is now per-event (5 events: chat opened, bot reply, agent message, rule
75
+ triggered, command executed) instead of one style for 3 hardcoded triggers — the two
76
+ new events (rule/command) get their own distinct tones per style.
77
+
78
+ ### Changed
79
+ - **BREAKING:** `ChatSoundPlayer.playOpen/playReply/playAgent` replaced by a single
80
+ `play(event)`; `bot-reply` payloads now carry an `event` field the sound engine reads
81
+ to pick the right style.
82
+
83
+ ## [0.6.0] - 2026-08-22
84
+
85
+ ### Added
86
+ - Three notification sound styles — Suave, Clásico, Campanita — each with its own
87
+ waveform, gain, and tone set for the open/reply/agent triggers, selected via the
88
+ site's `soundStyle` config.
89
+
90
+ ## [0.5.0] - 2026-08-22
91
+
92
+ ### Added
93
+ - Notification sounds, synthesized via Web Audio (no audio assets): a chime when the
94
+ chat opens, a shorter tone on a bot reply, and a distinct two-note tone when a human
95
+ agent's message arrives. Gated by the site's `soundEnabled` config; playback lives in
96
+ the loader, not the iframe, since only its launcher click carries a genuine user
97
+ gesture the autoplay policy will accept.
98
+
99
+ ## [0.4.0] - 2026-08-22
100
+
101
+ ### Added
102
+ - The visitor's own typing activity is now relayed to the admin portal (debounced the
103
+ same way the admin's own typing signal already was), so an agent can see someone is
104
+ drafting a reply.
105
+
106
+ ## [0.3.2] - 2026-08-22
107
+
108
+ ### Fixed
109
+ - `server.mjs` now serves `fixtures/` under `/fixtures/` too, not just `dist/` at the
110
+ root — the demo fixtures need to be opened from this server's own origin for the
111
+ backend's Origin check to pass, so opening them as `file://` (or 404ing) silently
112
+ dropped every message: no bot reply, nothing saved, nothing visible from any admin view.
113
+
114
+ ## [0.3.1] - 2026-08-22
115
+
116
+ ### Fixed
117
+ - `fixtures/demo-sites/*.html` had stale API keys and mismatched business names from
118
+ before the backend's realistic-10-tenant reseed — each now points at its real,
119
+ currently-valid counterpart.
120
+
121
+ ## [0.3.0] - 2026-08-22
122
+
123
+ ### Added
124
+ - Launcher icon, send-button label, and emoji picker visibility now come from the site's
125
+ own config instead of being fixed.
126
+ - Visitors can attach a file to their own message when the site enables it — relayed
127
+ through loader.ts (the only context with the api key and a real Origin) via a new
128
+ postMessage exchange, not made directly from the sandboxed iframe.
129
+
130
+ ## [0.2.0] - 2026-08-21
131
+
132
+ ### Added
133
+ - Admin replies rendered as a distinct bubble from automated bot replies, with their
134
+ attachment (image thumbnail or file link) when present.
135
+ - A typing-dots indicator while the admin is drafting a reply.
136
+ - A self-contained emoji picker in the composer (no new dependency).
137
+
138
+ ### Fixed
139
+ - The iframe's CSP `img-src` now allows the API's own origin, so admin-attachment
140
+ images actually load instead of being blocked.
141
+
142
+ ## [0.1.0] - 2026-08-20
143
+
144
+ Baseline — formal versioning and changelog tracking starts here. Prior history (chat
145
+ history restore on reload, demo site fixtures) is available via `git log` but not
146
+ itemized in this file.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @zabbu/chat-widget
2
+
3
+ Embeddable chat widget — loader script + sandboxed chat UI — for a site backed by
4
+ [Zabbu](https://github.com/zabbu-app/zabbu-chat-portal). Ships as a single
5
+ self-contained script; no build step or framework required on the host page.
6
+
7
+ ## Install
8
+
9
+ Add the script tag anywhere on your page, with the site key from your Zabbu admin panel:
10
+
11
+ ```html
12
+ <script
13
+ async
14
+ src="https://unpkg.com/@zabbu/chat-widget/dist/loader.js"
15
+ data-site-key="YOUR_SITE_KEY"
16
+ ></script>
17
+ ```
18
+
19
+ That's it — the launcher appears bottom-right, styled with whatever your site's admin
20
+ panel has configured (color, welcome text, shadow style, etc).
21
+
22
+ > Use unpkg, not jsDelivr, for this package — jsDelivr serves `.html` as `text/plain`
23
+ > (an anti-phishing measure on their end, not something this package can opt out of),
24
+ > which breaks the widget's iframe. unpkg serves it correctly.
25
+
26
+ ## Configuring without the admin panel
27
+
28
+ Every `data-*` attribute below overrides the site's saved config for visitors of *this*
29
+ particular embed, without touching the admin panel:
30
+
31
+ | Attribute | Values | |
32
+ |---|---|---|
33
+ | `data-primary-color` | any CSS color, e.g. `#16a34a` | Launcher, panel, and header accent |
34
+ | `data-position` | `bottom-right` (default) \| `bottom-left` | Which corner the widget docks to |
35
+ | `data-welcome-text` | any string | First message shown to a new visitor |
36
+ | `data-color-scheme` | `light` (default) \| `dark` | Panel theme |
37
+ | `data-api-base` | a URL | Overrides the backend this build was published against (rarely needed) |
38
+
39
+ ## Programmatic API
40
+
41
+ For host pages that want to control the widget from their own code — open it from a
42
+ custom button, wait for it to be ready, react to a reply arriving — a script tag with no
43
+ `data-site-key` stays inert until you call `init()` yourself:
44
+
45
+ ```html
46
+ <script async src="https://unpkg.com/@zabbu/chat-widget/dist/loader.js"></script>
47
+ <script>
48
+ window.addEventListener("load", () => {
49
+ const widget = Zabbu.init({
50
+ siteKey: "YOUR_SITE_KEY",
51
+ primaryColor: "#16a34a",
52
+ position: "bottom-left",
53
+ welcomeText: "Hey, need a hand?",
54
+ });
55
+
56
+ widget.on("message", ({ text }) => console.log("new reply:", text));
57
+ });
58
+ </script>
59
+ ```
60
+
61
+ `Zabbu.init()` is idempotent — safe to call again later (e.g. once you know a logged-in
62
+ user's preferred color); it returns the existing widget instead of creating a second one.
63
+
64
+ ### Methods
65
+
66
+ | | |
67
+ |---|---|
68
+ | `Zabbu.init(config)` | Creates the widget if it doesn't exist yet; returns it either way. `config.siteKey` is required. |
69
+ | `Zabbu.open()` / `.close()` / `.toggle()` | Control the panel. No-ops (with a console warning) before `init()`. |
70
+ | `Zabbu.on(event, handler)` / `.off(event, handler)` | Subscribe/unsubscribe. |
71
+
72
+ ### Events
73
+
74
+ | Event | Payload | Fires when |
75
+ |---|---|---|
76
+ | `ready` | — | The widget's DOM and appearance are set up. Replays immediately if you subscribe after it already fired. |
77
+ | `open` / `close` | — | The panel is toggled — by the visitor, or by `Zabbu.open()`/`.close()`. |
78
+ | `message` | `{ text: string }` | A bot or admin reply arrives. |
79
+
80
+ If the widget auto-inited via `data-site-key` and you need to call a method on it later
81
+ from unrelated code, call `Zabbu.init()` again with the same `siteKey` — it's idempotent
82
+ and returns the existing instance rather than creating a second one.
83
+
84
+ ## Version history
85
+
86
+ See [CHANGELOG.md](./CHANGELOG.md).
87
+
88
+ ## License
89
+
90
+ MIT
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@zabbu/chat-widget",
3
- "version": "0.10.0",
4
- "description": "Embeddable chat widget (loader.js + chat UI) for the chat portal backend (zabbu-chat-portal). Served standalone see server.mjs and Dockerfile.",
3
+ "version": "0.10.1",
4
+ "description": "Embeddable, multi-tenant chat widget a single <script> tag, with a programmatic JS API and per-embed config overrides.",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "CHANGELOG.md"
11
12
  ],
12
13
  "main": "dist/loader.js",
13
14
  "license": "MIT",