@personaliai/react-widget 0.1.0
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/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/chunk-PR4QN5HX.js +43 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/emoji-picker-react.esm-JCK7JWXK.js +26071 -0
- package/dist/emoji-picker-react.esm-JCK7JWXK.js.map +1 -0
- package/dist/index.cjs +98050 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +71952 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +259 -0
- package/package.json +57 -0
- package/src/ChatWidgetCore.tsx +1919 -0
- package/src/attach-menu.tsx +60 -0
- package/src/color-contrast.ts +186 -0
- package/src/index.ts +1 -0
- package/src/quick-emoji-picker.tsx +75 -0
- package/src/safe-markdown-link.tsx +44 -0
- package/src/voice-call-widget.tsx +564 -0
- package/src/widget-presets.css +259 -0
- package/src/widget-style.ts +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PersonaliAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @personaliai/react-widget
|
|
2
|
+
|
|
3
|
+
Embed the Chatty chat assistant directly inside a React app — calls the
|
|
4
|
+
Chatty API directly, no iframe involved. Same UI and behavior as the
|
|
5
|
+
hosted `/embed/[botId]` widget (this package's `ChattyWidget` component
|
|
6
|
+
*is* that same component, extracted).
|
|
7
|
+
|
|
8
|
+
## Why this exists
|
|
9
|
+
|
|
10
|
+
The default embed (`<script src="https://chatty.personaliai.com/widget.js">`)
|
|
11
|
+
loads the chat panel in an iframe. For a customer site on its own domain,
|
|
12
|
+
that's a **cross-origin** iframe, which Chrome's Site Isolation gives its
|
|
13
|
+
own separate rendering surface — this measurably softens text rendering
|
|
14
|
+
during/after browser zoom. For a React app that already has its own build
|
|
15
|
+
step, that iframe boundary is unnecessary: this package lets the same chat
|
|
16
|
+
UI run directly in the host page's own DOM instead, avoiding the cross-origin
|
|
17
|
+
surface entirely.
|
|
18
|
+
|
|
19
|
+
This does **not** replace `widget.js` for non-React sites (WordPress,
|
|
20
|
+
static HTML, Squarespace, etc.) — those still need a `<script>` tag, and
|
|
21
|
+
that's still iframe-based. This package is for teams building their own
|
|
22
|
+
React app who can `npm install` a component instead.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @personaliai/react-widget
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`react` and `react-dom` (>=18) are peer dependencies — everything else this
|
|
31
|
+
package needs (framer-motion, react-markdown, katex, livekit-client, etc.)
|
|
32
|
+
is bundled in.
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { ChattyWidget } from "@personaliai/react-widget";
|
|
38
|
+
import "@personaliai/react-widget/styles.css";
|
|
39
|
+
// Only needed if you use bot replies with math notation — same as the
|
|
40
|
+
// hosted embed, this isn't bundled in since it's ~1MB of embedded fonts.
|
|
41
|
+
import "katex/dist/katex.min.css";
|
|
42
|
+
|
|
43
|
+
function App() {
|
|
44
|
+
return (
|
|
45
|
+
<div style={{ position: "fixed", bottom: 20, right: 20, width: 380, height: 560 }}>
|
|
46
|
+
<ChattyWidget botId="YOUR_BOT_UUID" originToken={null} />
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`ChattyWidget` renders the full panel (header, messages, composer) filling
|
|
53
|
+
its container — it doesn't manage a floating launcher button, open/close
|
|
54
|
+
state, unread badge, or teaser message the way `widget.js` does. Wire your
|
|
55
|
+
own launcher button around it (show/hide the container, track unread via
|
|
56
|
+
the `onAssistantMessage` prop) the way this repo's own `EmbedClient.tsx`
|
|
57
|
+
wires it for the iframe route, or the way `widget.js` wires it for the
|
|
58
|
+
Shadow DOM mount in that (currently reverted) architecture.
|
|
59
|
+
|
|
60
|
+
## Props
|
|
61
|
+
|
|
62
|
+
See `ChattyWidgetProps` (exported from this package) for the full list —
|
|
63
|
+
it mirrors the bot's dashboard settings 1:1: `botId` (required),
|
|
64
|
+
`originToken`, `paramColor`, `paramStyle`, `paramName`, `paramWelcome`,
|
|
65
|
+
`paramAvatarIcon`, `paramAvatarUrl`, `paramLogoUrl`, `paramLogoBgColor`,
|
|
66
|
+
`paramShowSenderTag`, `paramCsatEnabled`, `paramColorScheme`, plus the
|
|
67
|
+
optional bridge props (`onWidgetReady`, `onWidgetClose`,
|
|
68
|
+
`onAssistantMessage`, `onRequestNotificationPermission`,
|
|
69
|
+
`onTriggerNotification`, `forceFullscreen`, `notificationGranted`) for
|
|
70
|
+
wiring your own launcher chrome around it.
|
|
71
|
+
|
|
72
|
+
Only `botId` is required — everything else defaults to the bot's own
|
|
73
|
+
saved dashboard settings, fetched live from the Chatty API on mount.
|
|
74
|
+
|
|
75
|
+
## Origin verification
|
|
76
|
+
|
|
77
|
+
`originToken` is optional. Passing `null` (as in the example above) means
|
|
78
|
+
every chat call falls into the backend's stricter *unverified-origin*
|
|
79
|
+
rate-limit tier — never a hard block, just a lower message-per-minute
|
|
80
|
+
ceiling (see `main.py`'s `_widget_rate_limit_or_429`). The hosted
|
|
81
|
+
`widget.js`/iframe path gets a verified token via a server-side Referer
|
|
82
|
+
exchange that only a real iframe navigation can produce; this package runs
|
|
83
|
+
directly in your own page with no equivalent mechanism, so there is
|
|
84
|
+
currently no way to mint one from here. If your usage needs the higher
|
|
85
|
+
rate-limit tier, get in touch about a proper API-key-based verification
|
|
86
|
+
path for direct SDK usage instead.
|
|
87
|
+
|
|
88
|
+
## Building this package
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
cd packages/chatty-react
|
|
92
|
+
npm install
|
|
93
|
+
npm run build # emits dist/index.{js,cjs,d.ts} + dist/styles.css
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Not currently published to a public npm registry — install via `file:` or
|
|
97
|
+
a private registry until that's set up.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
__require,
|
|
39
|
+
__commonJS,
|
|
40
|
+
__export,
|
|
41
|
+
__toESM
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=chunk-PR4QN5HX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|