@gymmymac/bob-widget 1.1.2 → 1.1.4
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 +108 -19
- package/dist/BobProvider.d.ts +4 -1
- package/dist/components/BobWidget.d.ts +67 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +13 -13
- package/dist/index.mjs +3185 -1946
- package/dist/version.d.ts +6 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,50 +1,102 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @gymmymac/bob-widget
|
|
2
2
|
|
|
3
3
|
AI-powered automotive parts assistant widget for integration into partner websites.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @gymmymac/bob-widget
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Quick Start
|
|
11
|
+
## Quick Start (Recommended)
|
|
12
|
+
|
|
13
|
+
The easiest way to integrate Bob - just use the `BobWidget` component:
|
|
12
14
|
|
|
13
15
|
```tsx
|
|
14
|
-
import {
|
|
16
|
+
import { BobWidget } from '@gymmymac/bob-widget';
|
|
15
17
|
|
|
16
18
|
function App() {
|
|
17
19
|
return (
|
|
18
|
-
<
|
|
20
|
+
<BobWidget
|
|
19
21
|
bobConfig={{
|
|
20
22
|
supabaseUrl: 'https://gjoguxzstsihhxvdgpto.supabase.co',
|
|
21
23
|
supabaseKey: 'eyJhbGciOiJI...', // Bob's public anon key
|
|
22
24
|
}}
|
|
23
25
|
hostApiConfig={{
|
|
24
26
|
baseUrl: 'https://api.yoursite.com',
|
|
25
|
-
apiKey: process.env.
|
|
27
|
+
apiKey: process.env.API_KEY!,
|
|
26
28
|
partnerCode: 'YOUR_PARTNER_CODE',
|
|
27
29
|
}}
|
|
28
30
|
hostContext={{
|
|
29
|
-
user: { id: user?.id, email: user?.email
|
|
31
|
+
user: { id: user?.id, email: user?.email },
|
|
30
32
|
vehicle: { selectedVehicle: currentVehicle },
|
|
31
33
|
}}
|
|
32
34
|
callbacks={{
|
|
33
35
|
onVehicleIdentified: (vehicle) => saveVehicle(vehicle),
|
|
34
|
-
|
|
36
|
+
onAddToCart: (item) => addToCart(item),
|
|
37
|
+
}}
|
|
38
|
+
variant="mobile"
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**That's it!** No `QueryClientProvider` wrapping needed - Bob handles everything internally.
|
|
45
|
+
|
|
46
|
+
## Alternative: BobProvider + Bob
|
|
47
|
+
|
|
48
|
+
If you need access to Bob's context in other components:
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import { BobProvider, Bob, useHostContext } from '@gymmymac/bob-widget';
|
|
52
|
+
|
|
53
|
+
function App() {
|
|
54
|
+
return (
|
|
55
|
+
<BobProvider
|
|
56
|
+
bobConfig={{
|
|
57
|
+
supabaseUrl: 'https://gjoguxzstsihhxvdgpto.supabase.co',
|
|
58
|
+
supabaseKey: 'eyJhbGciOiJI...',
|
|
59
|
+
}}
|
|
60
|
+
hostApiConfig={{
|
|
61
|
+
baseUrl: 'https://api.yoursite.com',
|
|
62
|
+
apiKey: process.env.API_KEY!,
|
|
63
|
+
partnerCode: 'YOUR_PARTNER_CODE',
|
|
64
|
+
}}
|
|
65
|
+
hostContext={{
|
|
66
|
+
user: { id: user?.id, email: user?.email },
|
|
67
|
+
}}
|
|
68
|
+
callbacks={{
|
|
35
69
|
onAddToCart: (item) => addToCart(item),
|
|
36
70
|
}}
|
|
37
71
|
>
|
|
38
72
|
<YourApp />
|
|
39
|
-
<Bob variant="
|
|
73
|
+
<Bob variant="mobile" />
|
|
40
74
|
</BobProvider>
|
|
41
75
|
);
|
|
42
76
|
}
|
|
43
77
|
```
|
|
44
78
|
|
|
79
|
+
## Checking Bob's Version
|
|
80
|
+
|
|
81
|
+
Ask Bob directly: "What version are you running?"
|
|
82
|
+
|
|
83
|
+
Or programmatically:
|
|
84
|
+
```tsx
|
|
85
|
+
import { BOB_VERSION, getBobVersion } from '@gymmymac/bob-widget';
|
|
86
|
+
|
|
87
|
+
console.log(`Bob Widget Version: ${getBobVersion()}`); // e.g., "1.1.4"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Check the console for startup logs:
|
|
91
|
+
```
|
|
92
|
+
[BobWidget] Package loaded - v1.1.4
|
|
93
|
+
[BobWidget] v1.1.4 initialized
|
|
94
|
+
[BobWidget] QueryClient: internal
|
|
95
|
+
```
|
|
96
|
+
|
|
45
97
|
## Configuration
|
|
46
98
|
|
|
47
|
-
### BobProvider Props
|
|
99
|
+
### BobWidget / BobProvider Props
|
|
48
100
|
|
|
49
101
|
| Prop | Type | Description |
|
|
50
102
|
|------|------|-------------|
|
|
@@ -52,6 +104,15 @@ function App() {
|
|
|
52
104
|
| `hostApiConfig` | `HostApiConfig` | Your API credentials for product/vehicle lookups |
|
|
53
105
|
| `hostContext` | `HostContext` | Current user, vehicle, cart, and purchase history |
|
|
54
106
|
| `callbacks` | `BobCallbacks` | Event handlers for Bob actions |
|
|
107
|
+
| `queryClient` | `QueryClient` | Optional: share your app's QueryClient |
|
|
108
|
+
|
|
109
|
+
### BobWidget Additional Props
|
|
110
|
+
|
|
111
|
+
| Prop | Type | Default | Description |
|
|
112
|
+
|------|------|---------|-------------|
|
|
113
|
+
| `variant` | `'mobile' \| 'inline' \| 'floating' \| 'fullscreen'` | `'mobile'` | Display variant |
|
|
114
|
+
| `showChat` | `boolean` | `true` | Show chat interface |
|
|
115
|
+
| `className` | `string` | `''` | Additional CSS classes |
|
|
55
116
|
|
|
56
117
|
### Host Context
|
|
57
118
|
|
|
@@ -87,22 +148,15 @@ Handle Bob's actions in your app:
|
|
|
87
148
|
|
|
88
149
|
```tsx
|
|
89
150
|
const callbacks = {
|
|
90
|
-
// Called when Bob identifies a vehicle
|
|
91
151
|
onVehicleIdentified: (vehicle) => {
|
|
92
152
|
dispatch(setCurrentVehicle(vehicle));
|
|
93
153
|
},
|
|
94
|
-
|
|
95
|
-
// Called when parts are found
|
|
96
154
|
onPartsFound: (parts) => {
|
|
97
155
|
dispatch(setParts(parts));
|
|
98
156
|
},
|
|
99
|
-
|
|
100
|
-
// Called when user wants to add to cart
|
|
101
157
|
onAddToCart: (item) => {
|
|
102
158
|
dispatch(addToCart(item));
|
|
103
159
|
},
|
|
104
|
-
|
|
105
|
-
// Called when checkout is requested
|
|
106
160
|
onCheckoutRequested: (url) => {
|
|
107
161
|
window.location.href = url;
|
|
108
162
|
},
|
|
@@ -111,14 +165,14 @@ const callbacks = {
|
|
|
111
165
|
|
|
112
166
|
## Hooks
|
|
113
167
|
|
|
114
|
-
Access Bob's context from anywhere in your app:
|
|
168
|
+
Access Bob's context from anywhere in your app (when using BobProvider):
|
|
115
169
|
|
|
116
170
|
```tsx
|
|
117
171
|
import {
|
|
118
172
|
useBobContext,
|
|
119
173
|
useHostContext,
|
|
120
174
|
useBobCallbacks,
|
|
121
|
-
} from '@
|
|
175
|
+
} from '@gymmymac/bob-widget';
|
|
122
176
|
|
|
123
177
|
function MyComponent() {
|
|
124
178
|
const { hostContext, updateHostContext } = useBobContext();
|
|
@@ -130,6 +184,41 @@ function MyComponent() {
|
|
|
130
184
|
}
|
|
131
185
|
```
|
|
132
186
|
|
|
187
|
+
## Advanced: Shared QueryClient
|
|
188
|
+
|
|
189
|
+
If you want Bob to share your app's React Query cache:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
193
|
+
import { BobProvider, Bob } from '@gymmymac/bob-widget';
|
|
194
|
+
|
|
195
|
+
const queryClient = new QueryClient();
|
|
196
|
+
|
|
197
|
+
function App() {
|
|
198
|
+
return (
|
|
199
|
+
<QueryClientProvider client={queryClient}>
|
|
200
|
+
<BobProvider
|
|
201
|
+
bobConfig={...}
|
|
202
|
+
hostApiConfig={...}
|
|
203
|
+
queryClient={queryClient} // Share the cache
|
|
204
|
+
>
|
|
205
|
+
<Bob variant="mobile" />
|
|
206
|
+
</BobProvider>
|
|
207
|
+
</QueryClientProvider>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Dependencies
|
|
213
|
+
|
|
214
|
+
Bob Widget v1.1.4+ bundles its own dependencies. You only need:
|
|
215
|
+
- `react` ^18.0.0
|
|
216
|
+
- `react-dom` ^18.0.0
|
|
217
|
+
|
|
218
|
+
## Integration Guide
|
|
219
|
+
|
|
220
|
+
For detailed integration instructions, see [CARFIX-INTEGRATION.md](./CARFIX-INTEGRATION.md).
|
|
221
|
+
|
|
133
222
|
## License
|
|
134
223
|
|
|
135
224
|
MIT
|
package/dist/BobProvider.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
3
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
4
|
import { BobConfig, HostApiConfig, HostContext, BobCallbacks } from './types';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -29,6 +30,8 @@ interface BobProviderProps {
|
|
|
29
30
|
hostContext?: HostContext;
|
|
30
31
|
/** Event callbacks */
|
|
31
32
|
callbacks?: BobCallbacks;
|
|
33
|
+
/** Optional external QueryClient - if not provided, an internal one is created */
|
|
34
|
+
queryClient?: QueryClient;
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* BobProvider - Context provider for the Bob widget
|
|
@@ -62,7 +65,7 @@ interface BobProviderProps {
|
|
|
62
65
|
* </BobProvider>
|
|
63
66
|
* ```
|
|
64
67
|
*/
|
|
65
|
-
export declare function BobProvider({ children, bobConfig, hostApiConfig, hostContext: initialHostContext, callbacks, }: BobProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
export declare function BobProvider({ children, bobConfig, hostApiConfig, hostContext: initialHostContext, callbacks, queryClient: externalQueryClient, }: BobProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
66
69
|
/**
|
|
67
70
|
* Hook to access Bob context
|
|
68
71
|
* Must be used within a BobProvider
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BobVariant } from './Bob';
|
|
3
|
+
import { BobConfig, HostApiConfig, HostContext, BobCallbacks } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Props for the self-contained BobWidget component
|
|
7
|
+
*/
|
|
8
|
+
export interface BobWidgetProps {
|
|
9
|
+
/** Bob's Supabase configuration (for animations, TTS) */
|
|
10
|
+
bobConfig: BobConfig;
|
|
11
|
+
/** Host's API configuration for product/vehicle lookups */
|
|
12
|
+
hostApiConfig: HostApiConfig;
|
|
13
|
+
/** Current host context (user, vehicle, cart, history) */
|
|
14
|
+
hostContext?: HostContext;
|
|
15
|
+
/** Event callbacks for Bob actions */
|
|
16
|
+
callbacks?: BobCallbacks;
|
|
17
|
+
/** Display variant */
|
|
18
|
+
variant?: BobVariant;
|
|
19
|
+
/** Initial animation state */
|
|
20
|
+
initialState?: string;
|
|
21
|
+
/** Show chat interface */
|
|
22
|
+
showChat?: boolean;
|
|
23
|
+
/** Additional CSS classes */
|
|
24
|
+
className?: string;
|
|
25
|
+
/** Custom backdrop URL (overrides database) */
|
|
26
|
+
backdropUrl?: string;
|
|
27
|
+
/** Custom counter overlay URL */
|
|
28
|
+
counterOverlayUrl?: string;
|
|
29
|
+
/** Counter height as percentage */
|
|
30
|
+
counterHeightPercent?: number;
|
|
31
|
+
/** Fallback Bob image URL */
|
|
32
|
+
defaultBobImage?: string;
|
|
33
|
+
/** Vertical offset for Bob character */
|
|
34
|
+
verticalOffset?: number;
|
|
35
|
+
/** Scale percentage for Bob character */
|
|
36
|
+
scale?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* BobWidget - Self-contained Bob widget component
|
|
40
|
+
*
|
|
41
|
+
* This is the easiest way to integrate Bob into your application.
|
|
42
|
+
* It handles all providers internally - no QueryClientProvider needed!
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* import { BobWidget } from '@gymmymac/bob-widget';
|
|
47
|
+
*
|
|
48
|
+
* function App() {
|
|
49
|
+
* return (
|
|
50
|
+
* <BobWidget
|
|
51
|
+
* bobConfig={{
|
|
52
|
+
* supabaseUrl: 'https://gjoguxzstsihhxvdgpto.supabase.co',
|
|
53
|
+
* supabaseKey: 'eyJhbGciOiJI...',
|
|
54
|
+
* }}
|
|
55
|
+
* hostApiConfig={{
|
|
56
|
+
* baseUrl: 'https://api.yoursite.com',
|
|
57
|
+
* apiKey: process.env.API_KEY!,
|
|
58
|
+
* partnerCode: 'YOUR_CODE',
|
|
59
|
+
* }}
|
|
60
|
+
* variant="mobile"
|
|
61
|
+
* />
|
|
62
|
+
* );
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare const BobWidget: React.FC<BobWidgetProps>;
|
|
67
|
+
export default BobWidget;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
* @gymmymac/bob-widget
|
|
3
3
|
*
|
|
4
4
|
* AI-powered automotive parts assistant widget - Full immersive experience
|
|
5
|
+
*
|
|
6
|
+
* v1.1.4+ - Self-contained with internal QueryClientProvider
|
|
5
7
|
*/
|
|
8
|
+
export { BOB_VERSION, getBobVersion } from './version';
|
|
6
9
|
export { BobProvider, useBobContext, useBobSupabase, useHostContext, useHostApiConfig, useBobCallbacks, } from './BobProvider';
|
|
10
|
+
export { BobWidget } from './components/BobWidget';
|
|
11
|
+
export type { BobWidgetProps } from './components/BobWidget';
|
|
7
12
|
export { Bob } from './components/Bob';
|
|
8
13
|
export type { BobVariant } from './components/Bob';
|
|
9
14
|
export { BobCharacter } from './components/BobCharacter';
|