@eventop/sdk 1.2.2 → 1.2.10
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 +86 -22
- package/dist/core.cjs +1347 -983
- package/dist/core.js +1347 -983
- package/dist/index.cjs +33 -36
- package/dist/index.d.ts +118 -35
- package/dist/index.js +33 -36
- package/dist/react/core.cjs +1347 -983
- package/dist/react/core.js +1347 -983
- package/dist/react/index.cjs +33 -36
- package/dist/react/index.d.ts +91 -13
- package/dist/react/index.js +33 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,8 +61,11 @@ app.post('/api/guide', async (req, res) => {
|
|
|
61
61
|
|
|
62
62
|
### 2. Add the provider at the root
|
|
63
63
|
|
|
64
|
+
Pass your router's navigate function so the SDK can move users between pages automatically.
|
|
65
|
+
|
|
64
66
|
```jsx
|
|
65
67
|
// main.jsx
|
|
68
|
+
import { useNavigate } from 'react-router-dom';
|
|
66
69
|
import { EventopAIProvider } from '@eventop/sdk/react';
|
|
67
70
|
|
|
68
71
|
const provider = async ({ systemPrompt, messages }) => {
|
|
@@ -75,9 +78,12 @@ const provider = async ({ systemPrompt, messages }) => {
|
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
export default function App() {
|
|
81
|
+
const navigate = useNavigate();
|
|
82
|
+
|
|
78
83
|
return (
|
|
79
84
|
<EventopAIProvider
|
|
80
85
|
provider={provider}
|
|
86
|
+
router={navigate}
|
|
81
87
|
appName="My App"
|
|
82
88
|
assistantName="AI Guide"
|
|
83
89
|
suggestions={['How do I export?', 'Invite a teammate']}
|
|
@@ -92,8 +98,10 @@ export default function App() {
|
|
|
92
98
|
|
|
93
99
|
### 3. Wrap features anywhere in the tree
|
|
94
100
|
|
|
101
|
+
Add `route` to any feature that lives on a different page. The SDK navigates there automatically when a tour needs it.
|
|
102
|
+
|
|
95
103
|
```jsx
|
|
96
|
-
// ExportPanel.jsx
|
|
104
|
+
// ExportPanel.jsx — lives on /canvas
|
|
97
105
|
import { EventopTarget } from '@eventop/sdk/react';
|
|
98
106
|
|
|
99
107
|
export function ExportPanel() {
|
|
@@ -102,6 +110,7 @@ export function ExportPanel() {
|
|
|
102
110
|
id="export"
|
|
103
111
|
name="Export Design"
|
|
104
112
|
description="Download the design as PNG, SVG or PDF"
|
|
113
|
+
route="/canvas"
|
|
105
114
|
>
|
|
106
115
|
<div id="export-panel">
|
|
107
116
|
<button>PNG</button>
|
|
@@ -113,7 +122,7 @@ export function ExportPanel() {
|
|
|
113
122
|
}
|
|
114
123
|
```
|
|
115
124
|
|
|
116
|
-
That's it. The chat bubble appears automatically. Users type what they need and
|
|
125
|
+
That's it. The chat bubble appears automatically. Users type what they need, the SDK figures out which page the feature is on, navigates there, and walks them through step by step.
|
|
117
126
|
|
|
118
127
|
---
|
|
119
128
|
|
|
@@ -159,12 +168,16 @@ export default async function handler(req, res) {
|
|
|
159
168
|
|
|
160
169
|
### 2. Add the provider in a client component
|
|
161
170
|
|
|
162
|
-
The SDK touches the DOM so the provider must be a client component.
|
|
171
|
+
The SDK touches the DOM so the provider must be a client component. Pass `router` so
|
|
172
|
+
the SDK can navigate between pages during a tour.
|
|
163
173
|
|
|
164
174
|
```jsx
|
|
165
175
|
// components/EventopProvider.jsx
|
|
166
176
|
'use client';
|
|
167
177
|
|
|
178
|
+
import { useRouter } from 'next/navigation'; // App Router
|
|
179
|
+
// import { useRouter } from 'next/router'; // Pages Router
|
|
180
|
+
|
|
168
181
|
import { EventopAIProvider } from '@eventop/sdk/react';
|
|
169
182
|
|
|
170
183
|
const provider = async ({ systemPrompt, messages }) => {
|
|
@@ -177,9 +190,12 @@ const provider = async ({ systemPrompt, messages }) => {
|
|
|
177
190
|
};
|
|
178
191
|
|
|
179
192
|
export function EventopProvider({ children }) {
|
|
193
|
+
const router = useRouter();
|
|
194
|
+
|
|
180
195
|
return (
|
|
181
196
|
<EventopAIProvider
|
|
182
197
|
provider={provider}
|
|
198
|
+
router={(path) => router.push(path)}
|
|
183
199
|
appName="My App"
|
|
184
200
|
assistantName="AI Guide"
|
|
185
201
|
suggestions={['How do I export?', 'Invite a teammate']}
|
|
@@ -212,9 +228,10 @@ export default function RootLayout({ children }) {
|
|
|
212
228
|
### 3. Wrap features in client components
|
|
213
229
|
|
|
214
230
|
Any component that uses `EventopTarget`, `EventopStep`, or the hooks needs `'use client'`.
|
|
231
|
+
Add `route` to features that live on a different page than where tours are typically started.
|
|
215
232
|
|
|
216
233
|
```jsx
|
|
217
|
-
// components/Toolbar.jsx
|
|
234
|
+
// components/Toolbar.jsx — lives on /canvas
|
|
218
235
|
'use client';
|
|
219
236
|
|
|
220
237
|
import { EventopTarget } from '@eventop/sdk/react';
|
|
@@ -226,6 +243,7 @@ export function Toolbar() {
|
|
|
226
243
|
id="export"
|
|
227
244
|
name="Export Design"
|
|
228
245
|
description="Download as PNG, SVG or PDF"
|
|
246
|
+
route="/canvas"
|
|
229
247
|
>
|
|
230
248
|
<button>Export</button>
|
|
231
249
|
</EventopTarget>
|
|
@@ -234,6 +252,7 @@ export function Toolbar() {
|
|
|
234
252
|
id="share"
|
|
235
253
|
name="Share Design"
|
|
236
254
|
description="Share a link to this design"
|
|
255
|
+
route="/canvas"
|
|
237
256
|
>
|
|
238
257
|
<button>Share</button>
|
|
239
258
|
</EventopTarget>
|
|
@@ -244,6 +263,49 @@ export function Toolbar() {
|
|
|
244
263
|
|
|
245
264
|
---
|
|
246
265
|
|
|
266
|
+
## Smart navigation
|
|
267
|
+
|
|
268
|
+
When a user asks about a feature that lives on a different page, the SDK handles
|
|
269
|
+
everything automatically — no manual navigation code needed.
|
|
270
|
+
|
|
271
|
+
**What the user sees:**
|
|
272
|
+
|
|
273
|
+
Before the tour starts, the chat panel tells them which pages will be visited:
|
|
274
|
+
|
|
275
|
+
> 🗺 This tour visits 2 areas: Export Design and Billing Settings. I'll navigate between them automatically.
|
|
276
|
+
|
|
277
|
+
Mid-tour, just before each page change:
|
|
278
|
+
|
|
279
|
+
> ↗ Taking you to the Billing Settings area…
|
|
280
|
+
|
|
281
|
+
The page changes, the target element appears, and the tooltip shows — all without
|
|
282
|
+
the user doing anything.
|
|
283
|
+
|
|
284
|
+
**How to set it up:**
|
|
285
|
+
|
|
286
|
+
Two things are required: `router` on the provider, and `route` on any `EventopTarget`
|
|
287
|
+
that lives on a different page.
|
|
288
|
+
|
|
289
|
+
```jsx
|
|
290
|
+
// Provider — pass your router once
|
|
291
|
+
<EventopAIProvider router={navigate} ...>
|
|
292
|
+
|
|
293
|
+
// Feature on /settings/billing
|
|
294
|
+
<EventopTarget id="billing" name="Billing" route="/settings/billing">
|
|
295
|
+
<BillingSection />
|
|
296
|
+
</EventopTarget>
|
|
297
|
+
|
|
298
|
+
// Feature on /canvas — no route needed if tours always start here
|
|
299
|
+
<EventopTarget id="export" name="Export">
|
|
300
|
+
<ExportButton />
|
|
301
|
+
</EventopTarget>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Features that share the page where tours are typically started don't need `route`.
|
|
305
|
+
Only add it to features on other pages.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
247
309
|
## Multi-step flows
|
|
248
310
|
|
|
249
311
|
For features that require multiple actions in sequence (open a panel, toggle a switch, adjust sliders), use `<EventopStep>`. Steps can live in completely different components — they self-assemble by index.
|
|
@@ -312,7 +374,7 @@ The parent feature still needs a `<EventopTarget>` somewhere:
|
|
|
312
374
|
id="drop-shadow"
|
|
313
375
|
name="Drop Shadow Effect"
|
|
314
376
|
description="Apply a customisable drop shadow to a selected element"
|
|
315
|
-
|
|
377
|
+
route="/canvas"
|
|
316
378
|
>
|
|
317
379
|
<div className="canvas-screen">
|
|
318
380
|
<CanvasStage />
|
|
@@ -393,26 +455,28 @@ export function TourStatusBar() {
|
|
|
393
455
|
|
|
394
456
|
### `<EventopAIProvider>`
|
|
395
457
|
|
|
396
|
-
| Prop | Type | Required | Default | Description
|
|
397
|
-
|
|
398
|
-
| `provider` | function | ✓ | — | Async function that calls your server route
|
|
399
|
-
| `appName` | string | ✓ | — | Shown in the chat header
|
|
400
|
-
| `assistantName` | string | | `'AI Guide'` | Name shown in the chat header
|
|
401
|
-
| `
|
|
402
|
-
| `
|
|
403
|
-
| `
|
|
458
|
+
| Prop | Type | Required | Default | Description |
|
|
459
|
+
|-----------------|------------|----------|----------------|----------------------------------------------------------------|
|
|
460
|
+
| `provider` | function | ✓ | — | Async function that calls your server route |
|
|
461
|
+
| `appName` | string | ✓ | — | Shown in the chat header |
|
|
462
|
+
| `assistantName` | string | | `'AI Guide'` | Name shown in the chat header |
|
|
463
|
+
| `router` | function | | — | `(path: string) => void` — your framework's navigate function. Used for cross-page tours. React Router: pass `useNavigate()`. Next.js: pass `(path) => router.push(path)`. Falls back to `history.pushState` if omitted. |
|
|
464
|
+
| `suggestions` | string[] | | `[]` | Clickable chips on first open |
|
|
465
|
+
| `theme` | object | | dark, default | `{ mode, preset, tokens }` |
|
|
466
|
+
| `position` | object | | bottom-right | `{ corner, offsetX, offsetY }` |
|
|
404
467
|
|
|
405
468
|
### `<EventopTarget>`
|
|
406
469
|
|
|
407
|
-
| Prop | Type | Required | Description
|
|
408
|
-
|
|
409
|
-
| `id` | string | ✓ | Unique feature id
|
|
410
|
-
| `name` | string | ✓ | Human-readable name the AI reads
|
|
411
|
-
| `description` | string | | What it does — AI uses this to match user intent
|
|
412
|
-
| `
|
|
413
|
-
| `
|
|
414
|
-
| `
|
|
415
|
-
| `
|
|
470
|
+
| Prop | Type | Required | Description |
|
|
471
|
+
|-------------------|----------|----------|------------------------------------------------------------------------------|
|
|
472
|
+
| `id` | string | ✓ | Unique feature id |
|
|
473
|
+
| `name` | string | ✓ | Human-readable name the AI reads |
|
|
474
|
+
| `description` | string | | What it does — AI uses this to match user intent |
|
|
475
|
+
| `route` | string | | Pathname where this feature lives (e.g. `"/settings/billing"`). When set, the SDK auto-navigates here before showing this step and explains the navigation to the user. |
|
|
476
|
+
| `navigate` | function | | Legacy: navigate here if component is not mounted. Prefer `route` + `router`.|
|
|
477
|
+
| `navigateWaitFor` | string | | CSS selector to wait for after navigating |
|
|
478
|
+
| `advanceOn` | object | | `{ event, delay?, selector? }` — auto-advance the tour |
|
|
479
|
+
| `waitFor` | string | | CSS selector to wait for before showing this step |
|
|
416
480
|
|
|
417
481
|
### `<EventopStep>`
|
|
418
482
|
|