@contentgrowth/llm-service 0.9.96 → 0.9.98
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.
|
@@ -258,6 +258,10 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
|
|
|
258
258
|
recognition.onend = () => {
|
|
259
259
|
console.log("[useSpeechRecognition] Native onend event fired. Timestamp:", Date.now());
|
|
260
260
|
isStartingRef.current = false;
|
|
261
|
+
if (recognitionRef.current === recognition) {
|
|
262
|
+
console.log("[useSpeechRecognition] Nullifying recognitionRef (onend)");
|
|
263
|
+
recognitionRef.current = null;
|
|
264
|
+
}
|
|
261
265
|
if (isSimulatingRef.current) {
|
|
262
266
|
console.log("[useSpeechRecognition] onend ignored - simulating");
|
|
263
267
|
return;
|
|
@@ -303,6 +307,10 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
|
|
|
303
307
|
} else if (event.error === "network") {
|
|
304
308
|
console.error("[useSpeechRecognition] - network: Network error during recognition");
|
|
305
309
|
}
|
|
310
|
+
if (recognitionRef.current === recognition) {
|
|
311
|
+
console.log("[useSpeechRecognition] Nullifying recognitionRef (onerror)");
|
|
312
|
+
recognitionRef.current = null;
|
|
313
|
+
}
|
|
306
314
|
isStartingRef.current = false;
|
|
307
315
|
if (event.error === "not-allowed" && process.env.NODE_ENV === "development") {
|
|
308
316
|
console.warn("Speech recognition blocked. Simulating input for development...");
|
|
@@ -363,6 +371,8 @@ var useSpeechRecognition = (onResult, onEnd, language = "en-US") => {
|
|
|
363
371
|
if (recognitionRef.current) {
|
|
364
372
|
console.log("[useSpeechRecognition] Stopping existing instance before creating new one");
|
|
365
373
|
try {
|
|
374
|
+
recognitionRef.current.onend = null;
|
|
375
|
+
recognitionRef.current.onerror = null;
|
|
366
376
|
recognitionRef.current.stop();
|
|
367
377
|
} catch (e) {
|
|
368
378
|
}
|
|
@@ -557,7 +567,7 @@ var ChatInputArea = forwardRef(({
|
|
|
557
567
|
if (typeof arg === "object") return JSON.stringify(arg);
|
|
558
568
|
return String(arg);
|
|
559
569
|
}).join(" ");
|
|
560
|
-
setLogs((prev) => [`[${formatTime()}] [${type}] ${msg}
|
|
570
|
+
setLogs((prev) => [...prev, `[${formatTime()}] [${type}] ${msg}`].slice(-50));
|
|
561
571
|
} catch (e) {
|
|
562
572
|
}
|
|
563
573
|
};
|
|
@@ -721,63 +731,50 @@ var ChatInputArea = forwardRef(({
|
|
|
721
731
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
722
732
|
}, []);
|
|
723
733
|
const startRecording = async (trigger) => {
|
|
734
|
+
var _a2, _b2;
|
|
724
735
|
console.log("[ChatInputArea] startRecording called. trigger:", trigger, "isMobile:", isMobile());
|
|
725
736
|
console.log("[ChatInputArea] Current state - voiceTrigger:", voiceTrigger, "isTranscribing:", isTranscribing);
|
|
726
737
|
if (voiceTrigger || isTranscribing) {
|
|
727
738
|
console.log("[ChatInputArea] startRecording ignored - already active");
|
|
728
739
|
return;
|
|
729
740
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
if (
|
|
735
|
-
console.
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
setVoiceTrigger(null);
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
console.log("[ChatInputArea] Calling nativeSpeech.start()...");
|
|
743
|
-
nativeSpeech.start();
|
|
744
|
-
console.log("[ChatInputArea] nativeSpeech.start() called");
|
|
745
|
-
console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (after nativeSpeech.start)...");
|
|
746
|
-
try {
|
|
747
|
-
(_a2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _a2.call(voiceConfig);
|
|
748
|
-
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
749
|
-
} catch (e) {
|
|
750
|
-
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
751
|
-
}
|
|
752
|
-
} else {
|
|
753
|
-
console.log("[ChatInputArea] Using custom recorder");
|
|
754
|
-
console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (custom mode)...");
|
|
755
|
-
try {
|
|
756
|
-
(_b2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _b2.call(voiceConfig);
|
|
757
|
-
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
758
|
-
} catch (e) {
|
|
759
|
-
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
760
|
-
}
|
|
761
|
-
await customRecorder.start();
|
|
762
|
-
console.log("[ChatInputArea] Custom recorder started");
|
|
741
|
+
setVoiceTrigger(trigger);
|
|
742
|
+
setVoiceError(null);
|
|
743
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") {
|
|
744
|
+
console.log("[ChatInputArea] Using native speech recognition");
|
|
745
|
+
if (!nativeSpeech.isSupported) {
|
|
746
|
+
console.error("[ChatInputArea] Native speech not supported");
|
|
747
|
+
alert("Speech recognition is not supported in this browser.");
|
|
748
|
+
setVoiceTrigger(null);
|
|
749
|
+
return;
|
|
763
750
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
console.log("[ChatInputArea]
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
751
|
+
console.log("[ChatInputArea] Calling nativeSpeech.start()...");
|
|
752
|
+
nativeSpeech.start();
|
|
753
|
+
console.log("[ChatInputArea] nativeSpeech.start() called");
|
|
754
|
+
console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists...");
|
|
755
|
+
try {
|
|
756
|
+
(_a2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _a2.call(voiceConfig);
|
|
757
|
+
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
758
|
+
} catch (e) {
|
|
759
|
+
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
770
760
|
}
|
|
771
|
-
console.log("[ChatInputArea] Mobile: Waiting 300ms before starting recognition...");
|
|
772
|
-
setTimeout(() => {
|
|
773
|
-
performStart();
|
|
774
|
-
}, 300);
|
|
775
761
|
} else {
|
|
776
|
-
|
|
762
|
+
console.log("[ChatInputArea] Using custom recorder");
|
|
763
|
+
console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (custom mode)...");
|
|
764
|
+
try {
|
|
765
|
+
(_b2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _b2.call(voiceConfig);
|
|
766
|
+
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
767
|
+
} catch (e) {
|
|
768
|
+
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
769
|
+
}
|
|
770
|
+
await customRecorder.start();
|
|
771
|
+
console.log("[ChatInputArea] Custom recorder started");
|
|
772
|
+
}
|
|
773
|
+
if (!isMobile()) {
|
|
777
774
|
console.log("[ChatInputArea] Re-focusing textarea (desktop only)");
|
|
778
775
|
setTimeout(() => {
|
|
779
|
-
var
|
|
780
|
-
return (
|
|
776
|
+
var _a3;
|
|
777
|
+
return (_a3 = textareaRef.current) == null ? void 0 : _a3.focus();
|
|
781
778
|
}, 0);
|
|
782
779
|
}
|
|
783
780
|
};
|
|
@@ -1002,7 +999,7 @@ var TapToTalk = ({
|
|
|
1002
999
|
if (typeof arg === "object") return JSON.stringify(arg);
|
|
1003
1000
|
return String(arg);
|
|
1004
1001
|
}).join(" ");
|
|
1005
|
-
setLogs((prev) => [`[${formatTime()}] [${type}] ${msg}
|
|
1002
|
+
setLogs((prev) => [...prev, `[${formatTime()}] [${type}] ${msg}`].slice(-50));
|
|
1006
1003
|
} catch (e) {
|
|
1007
1004
|
}
|
|
1008
1005
|
};
|
|
@@ -1077,10 +1074,6 @@ var TapToTalk = ({
|
|
|
1077
1074
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
1078
1075
|
}, []);
|
|
1079
1076
|
const toggleVoice = async (e) => {
|
|
1080
|
-
if (e) {
|
|
1081
|
-
e.preventDefault();
|
|
1082
|
-
e.stopPropagation();
|
|
1083
|
-
}
|
|
1084
1077
|
const now = Date.now();
|
|
1085
1078
|
if (now - tapCountRef.current.lastTap < 500) {
|
|
1086
1079
|
tapCountRef.current.count++;
|
|
@@ -1122,47 +1115,33 @@ var TapToTalk = ({
|
|
|
1122
1115
|
} else {
|
|
1123
1116
|
console.log("[TapToTalk] Starting voice... mode:", voiceConfig == null ? void 0 : voiceConfig.mode);
|
|
1124
1117
|
setErrorMsg(null);
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
if (!nativeSpeech.isSupported) {
|
|
1141
|
-
console.error("[TapToTalk] Native speech not supported");
|
|
1142
|
-
setErrorMsg("Speech not supported");
|
|
1143
|
-
setVoiceTrigger(null);
|
|
1144
|
-
return;
|
|
1145
|
-
}
|
|
1146
|
-
console.log("[TapToTalk] Calling nativeSpeech.start()...");
|
|
1147
|
-
nativeSpeech.start();
|
|
1148
|
-
console.log("[TapToTalk] nativeSpeech.start() called");
|
|
1149
|
-
}
|
|
1150
|
-
};
|
|
1151
|
-
if (isMobile()) {
|
|
1152
|
-
console.log("[TapToTalk] Mobile: Blurring active element and skipping onFocusTarget");
|
|
1153
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
1154
|
-
document.activeElement.blur();
|
|
1118
|
+
setVoiceTrigger("click");
|
|
1119
|
+
console.log("[TapToTalk] voiceTrigger set to click");
|
|
1120
|
+
if (!isMobile() && onFocusTarget) {
|
|
1121
|
+
console.log("[TapToTalk] Desktop: calling onFocusTarget()");
|
|
1122
|
+
onFocusTarget();
|
|
1123
|
+
}
|
|
1124
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "custom") {
|
|
1125
|
+
console.log("[TapToTalk] Starting custom recorder...");
|
|
1126
|
+
try {
|
|
1127
|
+
await customRecorder.start();
|
|
1128
|
+
console.log("[TapToTalk] Custom recorder started successfully");
|
|
1129
|
+
} catch (e2) {
|
|
1130
|
+
console.error("[TapToTalk] Custom recorder failed:", e2);
|
|
1131
|
+
setErrorMsg("Mic access denied");
|
|
1132
|
+
setVoiceTrigger(null);
|
|
1155
1133
|
}
|
|
1156
|
-
console.log("[TapToTalk] Mobile: Waiting 300ms before starting recognition...");
|
|
1157
|
-
setTimeout(() => {
|
|
1158
|
-
performStart();
|
|
1159
|
-
}, 300);
|
|
1160
1134
|
} else {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1135
|
+
console.log("[TapToTalk] Starting native speech recognition...");
|
|
1136
|
+
if (!nativeSpeech.isSupported) {
|
|
1137
|
+
console.error("[TapToTalk] Native speech not supported");
|
|
1138
|
+
setErrorMsg("Speech not supported");
|
|
1139
|
+
setVoiceTrigger(null);
|
|
1140
|
+
return;
|
|
1164
1141
|
}
|
|
1165
|
-
|
|
1142
|
+
console.log("[TapToTalk] Calling nativeSpeech.start()...");
|
|
1143
|
+
nativeSpeech.start();
|
|
1144
|
+
console.log("[TapToTalk] nativeSpeech.start() called");
|
|
1166
1145
|
}
|
|
1167
1146
|
}
|
|
1168
1147
|
} finally {
|
|
@@ -1208,6 +1187,7 @@ var TapToTalk = ({
|
|
|
1208
1187
|
/* @__PURE__ */ jsxs4(
|
|
1209
1188
|
"button",
|
|
1210
1189
|
{
|
|
1190
|
+
type: "button",
|
|
1211
1191
|
onClick: toggleVoice,
|
|
1212
1192
|
disabled: disabled || isTranscribing && !isListening,
|
|
1213
1193
|
className: `flex items-center justify-center gap-3 px-6 py-3 rounded-xl transition-all duration-300 w-full font-medium shadow-md active:scale-[0.98]
|
|
@@ -1216,9 +1196,9 @@ var TapToTalk = ({
|
|
|
1216
1196
|
${className}`,
|
|
1217
1197
|
title: label,
|
|
1218
1198
|
children: [
|
|
1219
|
-
/* @__PURE__ */ jsx6("div", { className: "flex items-center justify-center shrink-0", children: Icon }),
|
|
1220
|
-
/* @__PURE__ */ jsx6("span", { className: "truncate", children: label }),
|
|
1221
|
-
errorMsg && /* @__PURE__ */ jsx6("span", { className: "text-[10px] bg-white/20 px-1.5 py-0.5 rounded text-red-100 animate-in fade-in slide-in-from-right-1", children: errorMsg })
|
|
1199
|
+
/* @__PURE__ */ jsx6("div", { className: "flex items-center justify-center shrink-0 pointer-events-none", children: Icon }),
|
|
1200
|
+
/* @__PURE__ */ jsx6("span", { className: "truncate pointer-events-none", children: label }),
|
|
1201
|
+
errorMsg && /* @__PURE__ */ jsx6("span", { className: "text-[10px] bg-white/20 px-1.5 py-0.5 rounded text-red-100 animate-in fade-in slide-in-from-right-1 pointer-events-none", children: errorMsg })
|
|
1222
1202
|
]
|
|
1223
1203
|
}
|
|
1224
1204
|
)
|