@gymmymac/bob-widget 3.0.4 → 3.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/README.md CHANGED
@@ -2,238 +2,50 @@
2
2
 
3
3
  AI-powered automotive parts assistant widget for integration into partner websites.
4
4
 
5
- **v3.0.0** - Major release with multi-tenant support, RAF animations, swipeable Bob, and enhanced mobile experience.
5
+ **Current Version:** 3.1.0
6
6
 
7
- ## What's New in v3.0.0
8
-
9
- - 🎭 **SwipeableBob**: Gesture-based interactions - swipe Bob away or back into view
10
- - 🏢 **Multi-Tenant Support**: Configurable looks and animations per tenant
11
- - 🎬 **RAF Animations**: Smooth 60fps animations using requestAnimationFrame
12
- - ⚡ **MatrixProductLoader**: Cyberpunk-style loading with phased states
13
- - 🔥 **SparkDealBanner**: Animated promotional banners
14
- - 👋 **Returning User Detection**: Personalized greetings for repeat visitors
15
- - 🎨 **Theme Settings**: Dynamic theme configuration from database
16
-
17
- ## Installation
18
-
19
- ```bash
20
- npm install @gymmymac/bob-widget
21
- ```
22
-
23
- ## Quick Start (Recommended)
24
-
25
- The easiest way to integrate Bob - just use the `BobWidget` component:
26
-
27
- ```tsx
28
- import { BobWidget } from '@gymmymac/bob-widget';
29
-
30
- function App() {
31
- return (
32
- <BobWidget
33
- bobConfig={{
34
- supabaseUrl: 'https://gjoguxzstsihhxvdgpto.supabase.co',
35
- supabaseKey: 'eyJhbGciOiJI...', // Bob's public anon key
36
- }}
37
- hostApiConfig={{
38
- baseUrl: 'https://api.yoursite.com',
39
- apiKey: process.env.API_KEY!,
40
- partnerCode: 'YOUR_PARTNER_CODE',
41
- }}
42
- hostContext={{
43
- user: { id: user?.id, email: user?.email },
44
- vehicle: { selectedVehicle: currentVehicle },
45
- }}
46
- callbacks={{
47
- onVehicleIdentified: (vehicle) => saveVehicle(vehicle),
48
- onAddToCart: (item) => addToCart(item),
49
- }}
50
- variant="mobile"
51
- />
52
- );
53
- }
54
- ```
55
-
56
- **That's it!** No `QueryClientProvider` wrapping needed - Bob handles everything internally.
57
-
58
- ## Alternative: BobProvider + Bob
59
-
60
- If you need access to Bob's context in other components:
7
+ ## Quick Start
61
8
 
62
9
  ```tsx
63
- import { BobProvider, Bob, useHostContext } from '@gymmymac/bob-widget';
64
-
65
- function App() {
66
- return (
67
- <BobProvider
68
- bobConfig={{
69
- supabaseUrl: 'https://gjoguxzstsihhxvdgpto.supabase.co',
70
- supabaseKey: 'eyJhbGciOiJI...',
71
- }}
72
- hostApiConfig={{
73
- baseUrl: 'https://api.yoursite.com',
74
- apiKey: process.env.API_KEY!,
75
- partnerCode: 'YOUR_PARTNER_CODE',
76
- }}
77
- hostContext={{
78
- user: { id: user?.id, email: user?.email },
79
- }}
80
- callbacks={{
81
- onAddToCart: (item) => addToCart(item),
82
- }}
83
- >
84
- <YourApp />
85
- <Bob variant="mobile" />
86
- </BobProvider>
87
- );
88
- }
89
- ```
90
-
91
- ## Checking Bob's Version
92
-
93
- Ask Bob directly: "What version are you running?"
10
+ import { BobStandalone } from '@gymmymac/bob-widget';
94
11
 
95
- Or programmatically:
96
- ```tsx
97
- import { BOB_VERSION, getBobVersion } from '@gymmymac/bob-widget';
98
-
99
- console.log(`Bob Widget Version: ${getBobVersion()}`); // "3.0.0"
100
- ```
101
-
102
- Check the console for startup logs:
103
- ```
104
- [BobWidget] Package loaded - v3.0.0
105
- [BobWidget] v3.0.0 initialized
106
- [BobWidget] QueryClient: internal
12
+ <BobStandalone
13
+ partner="CARFIX"
14
+ sessionToken={sessionToken}
15
+ onAddToCart={(item) => addToCart(item)}
16
+ onNavigate={(url) => router.push(url)}
17
+ />
107
18
  ```
108
19
 
109
- ## Configuration
20
+ **That's it!** Bob auto-configures from the database.
110
21
 
111
- ### BobWidget / BobProvider Props
22
+ ## Documentation
112
23
 
113
- | Prop | Type | Description |
114
- |------|------|-------------|
115
- | `bobConfig` | `BobConfig` | Bob's Supabase credentials (for animations, TTS) |
116
- | `hostApiConfig` | `HostApiConfig` | Your API credentials for product/vehicle lookups |
117
- | `hostContext` | `HostContext` | Current user, vehicle, cart, and purchase history |
118
- | `callbacks` | `BobCallbacks` | Event handlers for Bob actions |
119
- | `queryClient` | `QueryClient` | Optional: share your app's QueryClient |
24
+ 📖 **[Full Documentation](./BOB-DOCUMENTATION.md)** - Complete integration guide, props reference, behaviour guidelines, and troubleshooting.
120
25
 
121
- ### BobWidget Additional Props
26
+ 📋 **[Changelog](./CHANGELOG.md)** - Version history and release notes.
122
27
 
123
- | Prop | Type | Default | Description |
124
- |------|------|---------|-------------|
125
- | `variant` | `'mobile' \| 'inline' \| 'floating' \| 'fullscreen'` | `'mobile'` | Display variant |
126
- | `showChat` | `boolean` | `true` | Show chat interface |
127
- | `className` | `string` | `''` | Additional CSS classes |
128
-
129
- ### Host Context
130
-
131
- Pass your app's state to Bob for personalized interactions:
132
-
133
- ```tsx
134
- const hostContext = useMemo(() => ({
135
- user: {
136
- id: user?.id,
137
- email: user?.email,
138
- name: user?.name,
139
- isAuthenticated: !!user,
140
- },
141
- vehicle: {
142
- selectedVehicle: currentVehicle,
143
- garageVehicles: userVehicles,
144
- },
145
- cart: {
146
- items: cartItems,
147
- totalValue: cartTotal,
148
- },
149
- history: {
150
- purchases: orderHistory,
151
- lastOrderDate: lastOrder?.date,
152
- },
153
- currentPage: location.pathname,
154
- }), [user, currentVehicle, userVehicles, cartItems, cartTotal, orderHistory]);
155
- ```
156
-
157
- ### Callbacks
158
-
159
- Handle Bob's actions in your app:
160
-
161
- ```tsx
162
- const callbacks = {
163
- onVehicleIdentified: (vehicle) => {
164
- dispatch(setCurrentVehicle(vehicle));
165
- },
166
- onPartsFound: (parts) => {
167
- dispatch(setParts(parts));
168
- },
169
- onAddToCart: (item) => {
170
- dispatch(addToCart(item));
171
- },
172
- onCheckoutRequested: (url) => {
173
- window.location.href = url;
174
- },
175
- };
176
- ```
177
-
178
- ## Hooks
179
-
180
- Access Bob's context from anywhere in your app (when using BobProvider):
28
+ ## Installation
181
29
 
182
- ```tsx
183
- import {
184
- useBobContext,
185
- useHostContext,
186
- useBobCallbacks,
187
- } from '@gymmymac/bob-widget';
188
-
189
- function MyComponent() {
190
- const { hostContext, updateHostContext } = useBobContext();
191
-
192
- // Update context when your app state changes
193
- useEffect(() => {
194
- updateHostContext({ user: { email: newEmail } });
195
- }, [newEmail]);
196
- }
30
+ ```bash
31
+ npm install @gymmymac/bob-widget@^3.1.0
197
32
  ```
198
33
 
199
- ## Advanced: Shared QueryClient
200
-
201
- If you want Bob to share your app's React Query cache:
34
+ ## What's New in v3.1.0
202
35
 
203
- ```tsx
204
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
205
- import { BobProvider, Bob } from '@gymmymac/bob-widget';
206
-
207
- const queryClient = new QueryClient();
208
-
209
- function App() {
210
- return (
211
- <QueryClientProvider client={queryClient}>
212
- <BobProvider
213
- bobConfig={...}
214
- hostApiConfig={...}
215
- queryClient={queryClient} // Share the cache
216
- >
217
- <Bob variant="mobile" />
218
- </BobProvider>
219
- </QueryClientProvider>
220
- );
221
- }
222
- ```
36
+ - 🎯 **BobStandalone** - Auto-configures from database (4 lines to integrate)
37
+ - 🗄️ **Partner Config System** - All settings in `bob_partners` table
38
+ - 🎨 **CSS Variables** - Customizable blur, opacity, colors
39
+ - 🔍 **Debug Overlay** - Visual diagnostic tool
40
+ - 📦 **Simplified Callbacks** - Only 3 essential callbacks needed
223
41
 
224
42
  ## Dependencies
225
43
 
226
- Bob Widget v3.0.0+ bundles its own dependencies. You only need:
44
+ Only requires:
227
45
  - `react` ^18.0.0
228
46
  - `react-dom` ^18.0.0
229
47
 
230
- ## Changelog
231
-
232
- See [CHANGELOG.md](./CHANGELOG.md) for version history.
233
-
234
- ## Integration Guide
235
-
236
- For detailed integration instructions, see [CARFIX-INTEGRATION.md](./CARFIX-INTEGRATION.md).
48
+ All other dependencies are bundled.
237
49
 
238
50
  ## License
239
51
 
@@ -12,6 +12,8 @@ interface BobProps {
12
12
  defaultBobImage?: string;
13
13
  verticalOffset?: number;
14
14
  scale?: number;
15
+ /** Session token for pre-authenticated sessions (vehicle/user context) */
16
+ sessionToken?: string;
15
17
  }
16
18
  export declare const Bob: React.FC<BobProps>;
17
19
  export {};
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { PartnerConfig } from '../types/partner';
3
+
4
+ interface BobDebugOverlayProps {
5
+ partnerConfig: PartnerConfig | null;
6
+ sessionToken?: string;
7
+ }
8
+ export declare const BobDebugOverlay: React.FC<BobDebugOverlayProps>;
9
+ export default BobDebugOverlay;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { StandaloneWidgetProps } from '../types/partner';
3
+
4
+ /**
5
+ * BobStandalone - Simplified partner integration component
6
+ *
7
+ * Reduces integration from 30+ lines to just 4 lines of code.
8
+ * All configuration is auto-loaded from the bob_partners database table.
9
+ */
10
+ export declare const BobStandalone: React.FC<StandaloneWidgetProps>;
11
+ export default BobStandalone;
@@ -0,0 +1,30 @@
1
+ export interface BobHealthCheckResult {
2
+ healthy: boolean;
3
+ reason?: string;
4
+ activeLookId?: string;
5
+ activeLookName?: string;
6
+ stateCount: number;
7
+ states: string[];
8
+ missingCritical: string[];
9
+ frameCount: number;
10
+ }
11
+ /**
12
+ * Health check hook for verifying Bob's animation system connectivity.
13
+ * Use this to diagnose issues with animation state loading on external sites.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const { checkHealth } = useBobHealthCheck();
18
+ *
19
+ * useEffect(() => {
20
+ * checkHealth().then(result => {
21
+ * if (!result.healthy) {
22
+ * console.error('Bob health check failed:', result.reason);
23
+ * }
24
+ * });
25
+ * }, []);
26
+ * ```
27
+ */
28
+ export declare const useBobHealthCheck: () => {
29
+ checkHealth: () => Promise<BobHealthCheckResult>;
30
+ };
@@ -0,0 +1,40 @@
1
+ import { SupabaseClient } from '@supabase/supabase-js';
2
+ import { PartnerConfig, PartnerFeatureFlags } from '../types/partner';
3
+
4
+ export interface UsePartnerConfigResult {
5
+ /** Loaded partner configuration */
6
+ config: PartnerConfig | null;
7
+ /** Loading state */
8
+ isLoading: boolean;
9
+ /** Error if config failed to load */
10
+ error: Error | null;
11
+ /** Whether the current origin is allowed for this partner */
12
+ isOriginAllowed: boolean;
13
+ /** Supabase client configured for this partner */
14
+ supabaseClient: SupabaseClient | null;
15
+ /** Reload configuration */
16
+ reload: () => Promise<void>;
17
+ }
18
+ /**
19
+ * Hook to auto-load partner configuration from database
20
+ *
21
+ * @param partnerCode - Partner identifier (e.g., "CARFIX")
22
+ * @returns Partner configuration, loading state, and utilities
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * const { config, isLoading, error, supabaseClient } = usePartnerConfig('CARFIX');
27
+ *
28
+ * if (isLoading) return <LoadingSpinner />;
29
+ * if (error) return <ErrorMessage error={error} />;
30
+ *
31
+ * // Use config for layout, features, etc.
32
+ * const bottomOffset = config.default_bottom_offset;
33
+ * ```
34
+ */
35
+ export declare function usePartnerConfig(partnerCode: string | undefined): UsePartnerConfigResult;
36
+ /**
37
+ * Get feature flag value with default fallback
38
+ */
39
+ export declare function getFeatureFlag<K extends keyof PartnerFeatureFlags>(config: PartnerConfig | null, flag: K, defaultValue: PartnerFeatureFlags[K]): PartnerFeatureFlags[K];
40
+ export default usePartnerConfig;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * AI-powered automotive parts assistant widget - Full immersive experience
5
5
  *
6
+ * v3.1.0 - Standalone partner integration: auto-config from database, simplified props
6
7
  * v3.0.0 - Major rebuild with multi-tenant support, RAF animations, swipeable Bob
7
8
  * v1.4.0 - Redesigned PTT button: 3x larger, green "TALK" text, floating cartoon style
8
9
  * v1.3.1 - Bottom offset support for host navigation bars
@@ -12,6 +13,11 @@ export { BOB_VERSION, getBobVersion } from './version';
12
13
  export { BobProvider, useBobContext, useBobSupabase, useBobSupabaseSafe, useHostContext, useHostApiConfig, useBobCallbacks, useBobAnalyticsConfig, useBobAnalytics, useBobLayoutConfig, } from './BobProvider';
13
14
  export { BobWidget } from './components/BobWidget';
14
15
  export type { BobWidgetProps } from './components/BobWidget';
16
+ export { BobStandalone } from './components/BobStandalone';
17
+ export type { StandaloneWidgetProps } from './types/partner';
18
+ export { usePartnerConfig, getFeatureFlag } from './hooks/usePartnerConfig';
19
+ export type { PartnerConfig, PartnerFeatureFlags, EssentialCallbacks } from './types/partner';
20
+ export { BobDebugOverlay } from './components/BobDebugOverlay';
15
21
  export { Bob } from './components/Bob';
16
22
  export type { BobVariant } from './components/Bob';
17
23
  export { BobCharacter } from './components/BobCharacter';
@@ -35,6 +41,8 @@ export { useBobBackdrop } from './hooks/useBobBackdrop';
35
41
  export { useThemeSettings } from './hooks/useThemeSettings';
36
42
  export { useSparkDeals } from './hooks/useSparkDeals';
37
43
  export { useReturningUser } from './hooks/useReturningUser';
44
+ export { useBobHealthCheck } from './hooks/useBobHealthCheck';
45
+ export type { BobHealthCheckResult } from './hooks/useBobHealthCheck';
38
46
  export type { HostContext, HostUserContext, HostVehicleContext, HostCartContext, HostHistoryContext, BobConfig, HostApiConfig, BobCallbacks, BobProviderConfig, BobLayoutConfig, } from './types/context';
39
47
  export type { Vehicle } from './types/vehicle';
40
48
  export type { Product, APIPart, CartItem, ServicePackage, Partslot, QualityTiers, Part, } from './types/product';