Skip to content

Commit e7f785a

Browse files
authored
Merge pull request #3 from layercodedev/onMessage-cb
onMessage cb
2 parents a9e8bb0 + 4e91efd commit e7f785a

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Layercode",
33
"license": "MIT",
44
"name": "@layercode/react-sdk",
5-
"version": "2.0.2",
5+
"version": "2.0.4",
66
"description": "Layercode React SDK for integrating with React applications",
77
"type": "module",
88
"main": "./dist/index.js",
@@ -33,7 +33,7 @@
3333
"react"
3434
],
3535
"dependencies": {
36-
"@layercode/js-sdk": "^2.0.2"
36+
"@layercode/js-sdk": "^2.0.4"
3737
},
3838
"peerDependencies": {
3939
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
@@ -50,4 +50,4 @@
5050
"rollup": "^4.42.0",
5151
"typescript": "^5.8.3"
5252
}
53-
}
53+
}

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface UseLayercodeAgentOptions {
1313
onDisconnect?: () => void;
1414
onError?: (error: Error) => void;
1515
onDataMessage?: (data: any) => void;
16+
onMessage?: (data: any) => void;
1617
}
1718

1819
/**
@@ -26,7 +27,7 @@ const useLayercodeAgent = (
2627
options: UseLayercodeAgentOptions & Record<string, any>
2728
) => {
2829
// Extract public options
29-
const { agentId, conversationId, authorizeSessionEndpoint, metadata = {}, onConnect, onDisconnect, onError, onDataMessage } = options;
30+
const { agentId, conversationId, authorizeSessionEndpoint, metadata = {}, onConnect, onDisconnect, onError, onDataMessage, onMessage } = options;
3031

3132
const [status, setStatus] = useState('initializing');
3233
const [userAudioAmplitude, setUserAudioAmplitude] = useState(0);
@@ -55,6 +56,9 @@ const useLayercodeAgent = (
5556
onDataMessage: (data: any) => {
5657
onDataMessage?.(data);
5758
},
59+
onMessage: (data: any) => {
60+
onMessage?.(data);
61+
},
5862
onStatusChange: (newStatus: string) => {
5963
setStatus(newStatus);
6064
},

0 commit comments

Comments
 (0)