@deepagents/react-genai 7.5.2 → 7.6.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/README.md +68 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -10
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @deepagents/react-genai
|
|
2
|
+
|
|
3
|
+
React components that render AI SDK chat flows, trajectories, tools, citations, dynamic UI and interactive responses. A host is the app that renders these components. The host gives the transport, the tools and the clock.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i @deepagents/react-genai @zukhruf/ui @zukhruf/shadcn
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The peer dependencies are `@zukhruf/ui`, `react` 19 and `react-dom` 19. Install `@zukhruf/ui` yourself. npm does not install it for you when `legacy-peer-deps` is set.
|
|
12
|
+
|
|
13
|
+
## Stylesheets
|
|
14
|
+
|
|
15
|
+
Import the stylesheets in the Tailwind CSS v4 file of the host, after Tailwind. Use plain `@import` statements, without `layer()`:
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
@import 'tailwindcss';
|
|
19
|
+
@import '@zukhruf/shadcn/styles.css';
|
|
20
|
+
@import '@zukhruf/ui/styles.css';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Import `TheButton` directly from `@zukhruf/ui`. This package does not export it.
|
|
24
|
+
|
|
25
|
+
## The clock
|
|
26
|
+
|
|
27
|
+
`AssistantSnapshot` renders a `TheButton` of `@zukhruf/ui`. `TheButton` gets its clock from a `ClockProvider` above it, and throws at its first render when there is none. `AssistantSnapshot` renders inside the tree of the host, so this package gives no clock. The tree has one clock, and the host gives it.
|
|
28
|
+
|
|
29
|
+
The root of the host gives `globalThis`:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { ClockProvider } from '@zukhruf/ui';
|
|
33
|
+
import { createRoot } from 'react-dom/client';
|
|
34
|
+
|
|
35
|
+
createRoot(container).render(
|
|
36
|
+
<ClockProvider clock={globalThis}>
|
|
37
|
+
<App />
|
|
38
|
+
</ClockProvider>,
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
A test gives `createClock()` of `@sinonjs/fake-timers`:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { createClock } from '@sinonjs/fake-timers';
|
|
46
|
+
import { ClockProvider } from '@zukhruf/ui';
|
|
47
|
+
|
|
48
|
+
const clock = createClock();
|
|
49
|
+
|
|
50
|
+
render(
|
|
51
|
+
<ClockProvider clock={clock}>
|
|
52
|
+
<AssistantSnapshot message={message} renderContent={renderContent} />
|
|
53
|
+
</ClockProvider>,
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## One copy of @zukhruf/ui
|
|
58
|
+
|
|
59
|
+
The host and this package must use the same copy of `@zukhruf/ui`. Each copy has its own React context. A `ClockProvider` of one copy does not reach a `TheButton` of the other copy, and the button throws `No clock set, use ClockProvider to set one`. For this reason `@zukhruf/ui` is a peer dependency. npm refuses an install when the version of the host is out of the range.
|
|
60
|
+
|
|
61
|
+
## Move from 7.5.2
|
|
62
|
+
|
|
63
|
+
Version 7.5.2 lists `@zukhruf/ui` as a dependency, with the range `^0.8.10`. An install with no lockfile gets a version of `@zukhruf/ui` that has the clock. Then `AssistantSnapshot` throws `No clock set, use ClockProvider to set one` at render.
|
|
64
|
+
|
|
65
|
+
Do these steps:
|
|
66
|
+
|
|
67
|
+
1. Add `@zukhruf/ui` to the dependencies of the host.
|
|
68
|
+
2. If the host renders `AssistantSnapshot`, put a `ClockProvider` above it, at the root of the host.
|
package/dist/index.js
CHANGED
|
@@ -5385,7 +5385,7 @@ var Ac = (e) => {
|
|
|
5385
5385
|
}, ne = async (e) => {
|
|
5386
5386
|
try {
|
|
5387
5387
|
let t = await (await fetch(e)).blob();
|
|
5388
|
-
return new Promise((e) => {
|
|
5388
|
+
return await new Promise((e) => {
|
|
5389
5389
|
let n = new FileReader();
|
|
5390
5390
|
n.onloadend = () => e(typeof n.result == "string" ? n.result : null), n.onerror = () => e(null), n.readAsDataURL(t);
|
|
5391
5391
|
});
|