@usecrow/ui 0.1.74 → 0.1.75
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/dist/index.cjs +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1248,6 +1248,20 @@ function useCrowAPI({ onIdentified, onReset } = {}) {
|
|
|
1248
1248
|
case "close":
|
|
1249
1249
|
window.dispatchEvent(new CustomEvent("crow:close"));
|
|
1250
1250
|
break;
|
|
1251
|
+
case "sendMessage": {
|
|
1252
|
+
const msgText = typeof options === "string" ? options : opts?.text ?? opts?.message;
|
|
1253
|
+
if (!msgText) {
|
|
1254
|
+
console.error("[Crow] sendMessage() requires a text string or { text }");
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
window.dispatchEvent(new CustomEvent("crow:open"));
|
|
1258
|
+
setTimeout(() => {
|
|
1259
|
+
window.dispatchEvent(
|
|
1260
|
+
new CustomEvent("crow:sendMessage", { detail: { text: msgText } })
|
|
1261
|
+
);
|
|
1262
|
+
}, 50);
|
|
1263
|
+
break;
|
|
1264
|
+
}
|
|
1251
1265
|
case "setToolStatus":
|
|
1252
1266
|
if (typeof options !== "string") {
|
|
1253
1267
|
console.error("[Crow] setToolStatus() requires a string");
|
|
@@ -5015,6 +5029,10 @@ function CrowWidget({
|
|
|
5015
5029
|
useEffect(() => {
|
|
5016
5030
|
const handleOpen = () => setIsCollapsed(false);
|
|
5017
5031
|
const handleClose = () => setIsCollapsed(true);
|
|
5032
|
+
const handleSendMessage = (e) => {
|
|
5033
|
+
const text = e.detail?.text;
|
|
5034
|
+
if (text) handleSend(text);
|
|
5035
|
+
};
|
|
5018
5036
|
const handleSetSuggestions = (e) => {
|
|
5019
5037
|
const actions = e.detail;
|
|
5020
5038
|
if (Array.isArray(actions)) {
|
|
@@ -5024,6 +5042,7 @@ function CrowWidget({
|
|
|
5024
5042
|
};
|
|
5025
5043
|
window.addEventListener("crow:open", handleOpen);
|
|
5026
5044
|
window.addEventListener("crow:close", handleClose);
|
|
5045
|
+
window.addEventListener("crow:sendMessage", handleSendMessage);
|
|
5027
5046
|
window.addEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5028
5047
|
const pending = window.__crow_suggested_actions;
|
|
5029
5048
|
if (Array.isArray(pending) && pending.length > 0) {
|
|
@@ -5033,6 +5052,7 @@ function CrowWidget({
|
|
|
5033
5052
|
return () => {
|
|
5034
5053
|
window.removeEventListener("crow:open", handleOpen);
|
|
5035
5054
|
window.removeEventListener("crow:close", handleClose);
|
|
5055
|
+
window.removeEventListener("crow:sendMessage", handleSendMessage);
|
|
5036
5056
|
window.removeEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5037
5057
|
};
|
|
5038
5058
|
}, []);
|
|
@@ -5644,6 +5664,10 @@ function CrowCopilot({
|
|
|
5644
5664
|
useEffect(() => {
|
|
5645
5665
|
const handleOpen = () => setIsCollapsed(false);
|
|
5646
5666
|
const handleClose = () => setIsCollapsed(true);
|
|
5667
|
+
const handleSendMessage = (e) => {
|
|
5668
|
+
const text = e.detail?.text;
|
|
5669
|
+
if (text) handleSend(text);
|
|
5670
|
+
};
|
|
5647
5671
|
const handleSetSuggestions = (e) => {
|
|
5648
5672
|
const actions = e.detail;
|
|
5649
5673
|
if (Array.isArray(actions)) {
|
|
@@ -5653,6 +5677,7 @@ function CrowCopilot({
|
|
|
5653
5677
|
};
|
|
5654
5678
|
window.addEventListener("crow:open", handleOpen);
|
|
5655
5679
|
window.addEventListener("crow:close", handleClose);
|
|
5680
|
+
window.addEventListener("crow:sendMessage", handleSendMessage);
|
|
5656
5681
|
window.addEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5657
5682
|
const pending = window.__crow_suggested_actions;
|
|
5658
5683
|
if (Array.isArray(pending) && pending.length > 0) {
|
|
@@ -5662,6 +5687,7 @@ function CrowCopilot({
|
|
|
5662
5687
|
return () => {
|
|
5663
5688
|
window.removeEventListener("crow:open", handleOpen);
|
|
5664
5689
|
window.removeEventListener("crow:close", handleClose);
|
|
5690
|
+
window.removeEventListener("crow:sendMessage", handleSendMessage);
|
|
5665
5691
|
window.removeEventListener("crow:setSuggestedActions", handleSetSuggestions);
|
|
5666
5692
|
};
|
|
5667
5693
|
}, []);
|