admesh-ui-sdk 0.19.22 → 1.0.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/CHANGELOG.md +64 -0
- package/dist/components/AdMeshRecommendations.d.ts +69 -0
- package/dist/components/AdMeshRecommendations.d.ts.map +1 -0
- package/dist/components/WeaveAdFormatContainer.d.ts +43 -0
- package/dist/components/WeaveAdFormatContainer.d.ts.map +1 -0
- package/dist/context/AdMeshContext.d.ts +29 -0
- package/dist/context/AdMeshContext.d.ts.map +1 -0
- package/dist/context/AdMeshProvider.d.ts +34 -0
- package/dist/context/AdMeshProvider.d.ts.map +1 -0
- package/dist/hooks/useAdMesh.d.ts +43 -0
- package/dist/hooks/useAdMesh.d.ts.map +1 -0
- package/dist/hooks/useWeaveAdFormat.d.ts +42 -0
- package/dist/hooks/useWeaveAdFormat.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +912 -678
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/AdMeshSDK.d.ts +48 -0
- package/dist/sdk/AdMeshSDK.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,70 @@ All notable changes to the AdMesh UI SDK will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.0] - 2025-10-27
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
- **Removed deprecated Weave format support from AdMeshRecommendations component**
|
|
12
|
+
- Removed `format="weave"` option from AdMeshRecommendations
|
|
13
|
+
- Removed `llmOutputContainerId` prop from ShowRecommendationsOptions
|
|
14
|
+
- Removed `timeoutMs` prop from AdMeshRecommendations
|
|
15
|
+
- Removed `fallbackFormat` prop from AdMeshRecommendations
|
|
16
|
+
- Removed `handleWeaveFormat()` method from SDK (deprecated)
|
|
17
|
+
|
|
18
|
+
### Migration Guide
|
|
19
|
+
If you were using the deprecated Weave format pattern:
|
|
20
|
+
|
|
21
|
+
**Before (Deprecated):**
|
|
22
|
+
```typescript
|
|
23
|
+
<AdMeshRecommendations
|
|
24
|
+
messages={messages}
|
|
25
|
+
format="weave"
|
|
26
|
+
timeoutMs={1500}
|
|
27
|
+
fallbackFormat="citation"
|
|
28
|
+
/>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**After (Recommended):**
|
|
32
|
+
```typescript
|
|
33
|
+
<WeaveAdFormatContainer
|
|
34
|
+
messageId={msg.id}
|
|
35
|
+
fallbackUI={
|
|
36
|
+
<AdMeshRecommendations
|
|
37
|
+
messages={[msg]}
|
|
38
|
+
format="citation"
|
|
39
|
+
/>
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
{msg.content}
|
|
43
|
+
</WeaveAdFormatContainer>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- **WeaveAdFormatContainer component** - Recommended pattern for Weave Ad Format
|
|
48
|
+
- Automatically detects AdMesh links in LLM responses
|
|
49
|
+
- Fires exposure tracking for detected links
|
|
50
|
+
- Adds [Ad] labels to links
|
|
51
|
+
- Shows "Why this ad?" tooltip on hover
|
|
52
|
+
- Conditionally renders fallback UI only when no links detected
|
|
53
|
+
|
|
54
|
+
- **useWeaveAdFormat hook** - Automatic Weave Ad Format handling
|
|
55
|
+
- Scans for AdMesh links in container
|
|
56
|
+
- Fires exposure tracking
|
|
57
|
+
- Manages fallback UI rendering
|
|
58
|
+
- Supports streaming responses with MutationObserver
|
|
59
|
+
|
|
60
|
+
### Improved
|
|
61
|
+
- **Better separation of concerns** - Each component has single responsibility
|
|
62
|
+
- **Loose coupling** - Components are independent and reusable
|
|
63
|
+
- **Explicit control** - Developers explicitly provide fallbackUI prop
|
|
64
|
+
- **Cleaner architecture** - Single pattern for all cases
|
|
65
|
+
|
|
66
|
+
### Documentation
|
|
67
|
+
- Updated WEAVE_AD_FORMAT_EXAMPLES.md with new pattern
|
|
68
|
+
- Updated WEAVE_AD_FORMAT_INTEGRATION.md with recommended approach
|
|
69
|
+
- Added migration guides for existing users
|
|
70
|
+
- Created comprehensive integration documentation
|
|
71
|
+
|
|
8
72
|
## [0.19.22] - 2025-10-27
|
|
9
73
|
|
|
10
74
|
### Added
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface Message {
|
|
3
|
+
messageId: string;
|
|
4
|
+
role: 'user' | 'assistant';
|
|
5
|
+
content: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface AdMeshRecommendationsProps {
|
|
9
|
+
/** Array of messages in the conversation */
|
|
10
|
+
messages: Message[];
|
|
11
|
+
/** Recommendation format (default: 'auto')
|
|
12
|
+
*
|
|
13
|
+
* Note: For Weave Ad Format (where AdMesh links are embedded in LLM response),
|
|
14
|
+
* use WeaveAdFormatContainer component instead. This component is for displaying
|
|
15
|
+
* recommendations as a separate UI component.
|
|
16
|
+
*/
|
|
17
|
+
format?: 'auto' | 'product' | 'sidebar' | 'floating' | 'expandable' | 'conversation' | 'citation' | 'ecommerce';
|
|
18
|
+
/** Optional callback when recommendations are shown */
|
|
19
|
+
onRecommendationsShown?: (messageId: string) => void;
|
|
20
|
+
/** Optional callback on error */
|
|
21
|
+
onError?: (error: Error) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* AdMeshRecommendations - Automatic recommendation display component
|
|
25
|
+
*
|
|
26
|
+
* Displays recommendations as a separate UI component. Handles all the complexity:
|
|
27
|
+
* - Finds last assistant/user message pair
|
|
28
|
+
* - Generates container IDs for recommendations
|
|
29
|
+
* - Deduplicates messages
|
|
30
|
+
* - Calls SDK's showRecommendations()
|
|
31
|
+
*
|
|
32
|
+
* For Weave Ad Format (where AdMesh links are embedded in LLM response),
|
|
33
|
+
* use WeaveAdFormatContainer component instead.
|
|
34
|
+
*
|
|
35
|
+
* Developers just need to pass messages array!
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <AdMeshProvider apiKey={apiKey} chatId={chatId}>
|
|
40
|
+
* <Chat messages={messages} />
|
|
41
|
+
* <AdMeshRecommendations
|
|
42
|
+
* messages={messages}
|
|
43
|
+
* format="auto"
|
|
44
|
+
* onError={(error) => console.error(error)}
|
|
45
|
+
* />
|
|
46
|
+
* </AdMeshProvider>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* // For Weave Ad Format with embedded links:
|
|
52
|
+
* <AdMeshProvider apiKey={apiKey} chatId={chatId}>
|
|
53
|
+
* <Chat messages={messages} />
|
|
54
|
+
* </AdMeshProvider>
|
|
55
|
+
*
|
|
56
|
+
* // Inside Chat component:
|
|
57
|
+
* {messages.map((msg) => (
|
|
58
|
+
* <WeaveAdFormatContainer
|
|
59
|
+
* messageId={msg.id}
|
|
60
|
+
* fallbackUI={<AdMeshRecommendations messages={[msg]} format="citation" />}
|
|
61
|
+
* >
|
|
62
|
+
* {msg.content}
|
|
63
|
+
* </WeaveAdFormatContainer>
|
|
64
|
+
* ))}
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const AdMeshRecommendations: React.FC<AdMeshRecommendationsProps>;
|
|
68
|
+
export default AdMeshRecommendations;
|
|
69
|
+
//# sourceMappingURL=AdMeshRecommendations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdMeshRecommendations.d.ts","sourceRoot":"","sources":["../../src/components/AdMeshRecommendations.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAIzC,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,4CAA4C;IAC5C,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;IAEhH,uDAAuD;IACvD,sBAAsB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAErD,iCAAiC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CA8EtE,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface WeaveAdFormatContainerProps {
|
|
3
|
+
/** Unique ID for this message container */
|
|
4
|
+
messageId: string;
|
|
5
|
+
/** The LLM response content (may contain AdMesh links) */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Timeout for link detection (default: 900ms) */
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
/** Fallback format if no links detected (default: 'citation') */
|
|
10
|
+
fallbackFormat?: 'product' | 'citation';
|
|
11
|
+
/** Optional callback when AdMesh links are detected */
|
|
12
|
+
onLinksDetected?: (count: number) => void;
|
|
13
|
+
/** Optional callback when no links are detected (fallback should be rendered) */
|
|
14
|
+
onNoLinksDetected?: () => void;
|
|
15
|
+
/** Optional callback on error */
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
/** Optional CSS class for the container */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** Optional fallback UI component to render when no links are detected */
|
|
20
|
+
fallbackUI?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* WeaveAdFormatContainer - Automatic Weave Ad Format handling component
|
|
24
|
+
*
|
|
25
|
+
* Wraps LLM response content and automatically:
|
|
26
|
+
* - Detects AdMesh links in the content
|
|
27
|
+
* - Fires exposure tracking for detected links
|
|
28
|
+
* - Adds [Ad] labels to links
|
|
29
|
+
* - Shows "Why this ad?" tooltip on hover
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <WeaveAdFormatContainer
|
|
34
|
+
* messageId={message.id}
|
|
35
|
+
* onLinksDetected={(count) => console.log(`Found ${count} ads`)}
|
|
36
|
+
* >
|
|
37
|
+
* {llmResponseContent}
|
|
38
|
+
* </WeaveAdFormatContainer>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const WeaveAdFormatContainer: React.FC<WeaveAdFormatContainerProps>;
|
|
42
|
+
export default WeaveAdFormatContainer;
|
|
43
|
+
//# sourceMappingURL=WeaveAdFormatContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WeaveAdFormatContainer.d.ts","sourceRoot":"","sources":["../../src/components/WeaveAdFormatContainer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAGtC,MAAM,WAAW,2BAA2B;IAC1C,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAElB,0DAA0D;IAC1D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iEAAiE;IACjE,cAAc,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAExC,uDAAuD;IACvD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAE/B,iCAAiC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CA8CxE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AdMeshSDK } from '../sdk/AdMeshSDK';
|
|
3
|
+
import { AdMeshTheme } from '../types/index';
|
|
4
|
+
/**
|
|
5
|
+
* Context value provided by AdMeshProvider
|
|
6
|
+
*/
|
|
7
|
+
export interface AdMeshContextValue {
|
|
8
|
+
sdk: AdMeshSDK | null;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
chatId: string;
|
|
11
|
+
theme?: AdMeshTheme;
|
|
12
|
+
processedMessageIds: Set<string>;
|
|
13
|
+
markMessageAsProcessed: (messageId: string) => void;
|
|
14
|
+
isMessageProcessed: (messageId: string) => boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* React Context for AdMesh SDK
|
|
18
|
+
*
|
|
19
|
+
* Provides SDK instance and tracking state to all child components
|
|
20
|
+
*/
|
|
21
|
+
export declare const AdMeshContext: React.Context<AdMeshContextValue | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Hook to access AdMesh context
|
|
24
|
+
*
|
|
25
|
+
* @throws Error if used outside of AdMeshProvider
|
|
26
|
+
* @returns AdMeshContextValue
|
|
27
|
+
*/
|
|
28
|
+
export declare function useAdMeshContext(): AdMeshContextValue;
|
|
29
|
+
//# sourceMappingURL=AdMeshContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdMeshContext.d.ts","sourceRoot":"","sources":["../../src/context/AdMeshContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAwB,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAEjC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAGtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;IAGpB,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAGjC,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,kBAAkB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;CACpD;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,+CAEzB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,kBAAkB,CAWrD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AdMeshTheme } from '../types/index';
|
|
3
|
+
export interface AdMeshProviderProps {
|
|
4
|
+
/** AdMesh API key (required) */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
/** Chat/session ID (required) */
|
|
7
|
+
chatId: string;
|
|
8
|
+
/** Optional theme configuration */
|
|
9
|
+
theme?: AdMeshTheme;
|
|
10
|
+
/** Child components */
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* AdMeshProvider - Simplified SDK integration for React applications
|
|
15
|
+
*
|
|
16
|
+
* Handles:
|
|
17
|
+
* - SDK initialization and lifecycle management
|
|
18
|
+
* - Message deduplication tracking
|
|
19
|
+
* - Session and message ID management
|
|
20
|
+
* - Error handling and logging
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <AdMeshProvider
|
|
25
|
+
* apiKey={process.env.NEXT_PUBLIC_ADMESH_API_KEY}
|
|
26
|
+
* chatId={chatId}
|
|
27
|
+
* >
|
|
28
|
+
* <Chat messages={messages} />
|
|
29
|
+
* </AdMeshProvider>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const AdMeshProvider: React.FC<AdMeshProviderProps>;
|
|
33
|
+
export default AdMeshProvider;
|
|
34
|
+
//# sourceMappingURL=AdMeshProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdMeshProvider.d.ts","sourceRoot":"","sources":["../../src/context/AdMeshProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IAEf,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IAEf,mCAAmC;IACnC,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB,uBAAuB;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA4DxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AdMeshSDK } from '../sdk/AdMeshSDK';
|
|
2
|
+
import { AdMeshTheme } from '../types/index';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access AdMesh SDK and tracking state
|
|
5
|
+
*
|
|
6
|
+
* Must be used within an <AdMeshProvider>
|
|
7
|
+
*
|
|
8
|
+
* @returns Object with SDK instance and tracking methods
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { sdk, chatId, markMessageAsProcessed } = useAdMesh();
|
|
13
|
+
*
|
|
14
|
+
* // Use SDK to show recommendations
|
|
15
|
+
* await sdk?.showRecommendations({
|
|
16
|
+
* query: 'user query',
|
|
17
|
+
* containerId: 'recommendations-container',
|
|
18
|
+
* session_id: chatId,
|
|
19
|
+
* message_id: messageId
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Mark message as processed to avoid duplicates
|
|
23
|
+
* markMessageAsProcessed(messageId);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useAdMesh(): {
|
|
27
|
+
/** AdMesh SDK instance */
|
|
28
|
+
sdk: AdMeshSDK | null;
|
|
29
|
+
/** API key */
|
|
30
|
+
apiKey: string;
|
|
31
|
+
/** Chat/session ID */
|
|
32
|
+
chatId: string;
|
|
33
|
+
/** Theme configuration */
|
|
34
|
+
theme: AdMeshTheme | undefined;
|
|
35
|
+
/** Set of processed message IDs (for deduplication) */
|
|
36
|
+
processedMessageIds: Set<string>;
|
|
37
|
+
/** Mark a message as processed to prevent duplicate recommendations */
|
|
38
|
+
markMessageAsProcessed: (messageId: string) => void;
|
|
39
|
+
/** Check if a message has already been processed */
|
|
40
|
+
isMessageProcessed: (messageId: string) => boolean;
|
|
41
|
+
};
|
|
42
|
+
export default useAdMesh;
|
|
43
|
+
//# sourceMappingURL=useAdMesh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAdMesh.d.ts","sourceRoot":"","sources":["../../src/hooks/useAdMesh.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS;IAIrB,0BAA0B;;IAG1B,cAAc;;IAGd,sBAAsB;;IAGtB,0BAA0B;;IAG1B,uDAAuD;;IAGvD,uEAAuE;;IAGvE,oDAAoD;;EAGvD;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface UseWeaveAdFormatOptions {
|
|
2
|
+
/** Container ID for the LLM output (where AdMesh links will be detected) */
|
|
3
|
+
llmOutputContainerId: string;
|
|
4
|
+
/** Timeout for link detection (default: 900ms) */
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
/** Fallback format if no links detected (default: 'citation') */
|
|
7
|
+
fallbackFormat?: 'product' | 'citation';
|
|
8
|
+
/** Optional callback when AdMesh links are detected */
|
|
9
|
+
onLinksDetected?: (count: number) => void;
|
|
10
|
+
/** Optional callback when no links are detected (fallback should be rendered) */
|
|
11
|
+
onNoLinksDetected?: () => void;
|
|
12
|
+
/** Optional callback on error */
|
|
13
|
+
onError?: (error: Error) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* useWeaveAdFormat - Hook for automatic Weave Ad Format handling
|
|
17
|
+
*
|
|
18
|
+
* Automatically:
|
|
19
|
+
* - Detects AdMesh links in LLM output
|
|
20
|
+
* - Fires exposure tracking for detected links
|
|
21
|
+
* - Adds [Ad] labels to links
|
|
22
|
+
* - Shows "Why this ad?" tooltip on hover
|
|
23
|
+
* - Renders fallback UI if no links detected
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const { isProcessing, detectedLinksCount } = useWeaveAdFormat({
|
|
28
|
+
* llmOutputContainerId: 'llm-output-123',
|
|
29
|
+
* timeoutMs: 1500,
|
|
30
|
+
* fallbackFormat: 'citation'
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const useWeaveAdFormat: (options: UseWeaveAdFormatOptions) => {
|
|
35
|
+
isProcessing: boolean;
|
|
36
|
+
detectedLinksCount: number;
|
|
37
|
+
linksFound: boolean;
|
|
38
|
+
shouldRenderFallback: boolean;
|
|
39
|
+
processWeaveFormat: () => Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
export default useWeaveAdFormat;
|
|
42
|
+
//# sourceMappingURL=useWeaveAdFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWeaveAdFormat.d.ts","sourceRoot":"","sources":["../../src/hooks/useWeaveAdFormat.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,CAAC;IAE7B,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iEAAiE;IACjE,cAAc,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAExC,uDAAuD;IACvD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1C,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAE/B,iCAAiC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,uBAAuB;;;;;;CAsGhE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export { AdMeshRenderer } from './sdk/AdMeshRenderer';
|
|
|
11
11
|
export type { RenderOptions } from './sdk/AdMeshRenderer';
|
|
12
12
|
export { WeaveResponseProcessor } from './sdk/WeaveResponseProcessor';
|
|
13
13
|
export type { DetectedLink, ProcessorConfig } from './sdk/WeaveResponseProcessor';
|
|
14
|
+
export { AdMeshProvider } from './context/AdMeshProvider';
|
|
15
|
+
export type { AdMeshProviderProps } from './context/AdMeshProvider';
|
|
16
|
+
export { AdMeshRecommendations } from './components/AdMeshRecommendations';
|
|
17
|
+
export type { AdMeshRecommendationsProps } from './components/AdMeshRecommendations';
|
|
18
|
+
export { AdMeshContext, useAdMeshContext } from './context/AdMeshContext';
|
|
19
|
+
export type { AdMeshContextValue } from './context/AdMeshContext';
|
|
14
20
|
export { AdMeshEcommerceCards } from './components/AdMeshEcommerceCards';
|
|
15
21
|
export { AdMeshProductCard } from './components/AdMeshProductCard';
|
|
16
22
|
export { AdMeshInlineCard } from './components/AdMeshInlineCard';
|
|
@@ -20,9 +26,14 @@ export { AdMeshSummaryUnit } from './components/AdMeshSummaryUnit';
|
|
|
20
26
|
export { AdMeshViewabilityTracker } from './components/AdMeshViewabilityTracker';
|
|
21
27
|
export { AdMeshLinkTracker } from './components/AdMeshLinkTracker';
|
|
22
28
|
export { AdMeshBadge } from './components/AdMeshBadge';
|
|
29
|
+
export { WeaveAdFormatContainer } from './components/WeaveAdFormatContainer';
|
|
30
|
+
export type { WeaveAdFormatContainerProps } from './components/WeaveAdFormatContainer';
|
|
31
|
+
export { useAdMesh } from './hooks/useAdMesh';
|
|
23
32
|
export { useAdMeshStyles } from './hooks/useAdMeshStyles';
|
|
24
33
|
export { useAdMeshTracker } from './hooks/useAdMeshTracker';
|
|
25
34
|
export { useViewabilityTracker } from './hooks/useViewabilityTracker';
|
|
35
|
+
export { useWeaveAdFormat } from './hooks/useWeaveAdFormat';
|
|
36
|
+
export type { UseWeaveAdFormatOptions } from './hooks/useWeaveAdFormat';
|
|
26
37
|
export type { AdMeshTheme } from './types/index';
|
|
27
38
|
export declare const VERSION = "1.0.0";
|
|
28
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,0BAA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