@contentgrowth/llm-service 0.9.94 → 0.9.96
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.
|
@@ -588,6 +588,10 @@ var ChatInputArea = (0, import_react5.forwardRef)(({
|
|
|
588
588
|
const originalLog = console.log;
|
|
589
589
|
const originalWarn = console.warn;
|
|
590
590
|
const originalError = console.error;
|
|
591
|
+
const formatTime = () => {
|
|
592
|
+
const now = /* @__PURE__ */ new Date();
|
|
593
|
+
return `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}.${now.getMilliseconds().toString().padStart(3, "0")}`;
|
|
594
|
+
};
|
|
591
595
|
const addLog = (type, args) => {
|
|
592
596
|
try {
|
|
593
597
|
const msg = args.map((arg) => {
|
|
@@ -595,7 +599,7 @@ var ChatInputArea = (0, import_react5.forwardRef)(({
|
|
|
595
599
|
if (typeof arg === "object") return JSON.stringify(arg);
|
|
596
600
|
return String(arg);
|
|
597
601
|
}).join(" ");
|
|
598
|
-
setLogs((prev) => [`[${type}] ${msg}`, ...prev].slice(0, 50));
|
|
602
|
+
setLogs((prev) => [`[${formatTime()}] [${type}] ${msg}`, ...prev].slice(0, 50));
|
|
599
603
|
} catch (e) {
|
|
600
604
|
}
|
|
601
605
|
};
|
|
@@ -759,57 +763,64 @@ var ChatInputArea = (0, import_react5.forwardRef)(({
|
|
|
759
763
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
760
764
|
}, []);
|
|
761
765
|
const startRecording = async (trigger) => {
|
|
762
|
-
var _a2, _b2;
|
|
763
766
|
console.log("[ChatInputArea] startRecording called. trigger:", trigger, "isMobile:", isMobile());
|
|
764
767
|
console.log("[ChatInputArea] Current state - voiceTrigger:", voiceTrigger, "isTranscribing:", isTranscribing);
|
|
765
768
|
if (voiceTrigger || isTranscribing) {
|
|
766
769
|
console.log("[ChatInputArea] startRecording ignored - already active");
|
|
767
770
|
return;
|
|
768
771
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (
|
|
774
|
-
console.
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
772
|
+
const performStart = async () => {
|
|
773
|
+
var _a2, _b2;
|
|
774
|
+
setVoiceTrigger(trigger);
|
|
775
|
+
setVoiceError(null);
|
|
776
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") {
|
|
777
|
+
console.log("[ChatInputArea] Using native speech recognition");
|
|
778
|
+
if (!nativeSpeech.isSupported) {
|
|
779
|
+
console.error("[ChatInputArea] Native speech not supported");
|
|
780
|
+
alert("Speech recognition is not supported in this browser.");
|
|
781
|
+
setVoiceTrigger(null);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
console.log("[ChatInputArea] Calling nativeSpeech.start()...");
|
|
785
|
+
nativeSpeech.start();
|
|
786
|
+
console.log("[ChatInputArea] nativeSpeech.start() called");
|
|
787
|
+
console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (after nativeSpeech.start)...");
|
|
788
|
+
try {
|
|
789
|
+
(_a2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _a2.call(voiceConfig);
|
|
790
|
+
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
791
|
+
} catch (e) {
|
|
792
|
+
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
793
|
+
}
|
|
794
|
+
} else {
|
|
795
|
+
console.log("[ChatInputArea] Using custom recorder");
|
|
796
|
+
console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (custom mode)...");
|
|
797
|
+
try {
|
|
798
|
+
(_b2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _b2.call(voiceConfig);
|
|
799
|
+
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
800
|
+
} catch (e) {
|
|
801
|
+
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
802
|
+
}
|
|
803
|
+
await customRecorder.start();
|
|
804
|
+
console.log("[ChatInputArea] Custom recorder started");
|
|
778
805
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
console.log("[ChatInputArea]
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
786
|
-
} catch (e) {
|
|
787
|
-
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
806
|
+
};
|
|
807
|
+
if (isMobile()) {
|
|
808
|
+
console.log("[ChatInputArea] SKIPPING textarea focus on mobile to prevent keyboard conflict");
|
|
809
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
810
|
+
console.log("[ChatInputArea] Blur active element on mobile BEFORE start");
|
|
811
|
+
document.activeElement.blur();
|
|
788
812
|
}
|
|
813
|
+
console.log("[ChatInputArea] Mobile: Waiting 300ms before starting recognition...");
|
|
814
|
+
setTimeout(() => {
|
|
815
|
+
performStart();
|
|
816
|
+
}, 300);
|
|
789
817
|
} else {
|
|
790
|
-
|
|
791
|
-
console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (custom mode)...");
|
|
792
|
-
try {
|
|
793
|
-
(_b2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _b2.call(voiceConfig);
|
|
794
|
-
console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
|
|
795
|
-
} catch (e) {
|
|
796
|
-
console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
|
|
797
|
-
}
|
|
798
|
-
await customRecorder.start();
|
|
799
|
-
console.log("[ChatInputArea] Custom recorder started");
|
|
800
|
-
}
|
|
801
|
-
if (!isMobile()) {
|
|
818
|
+
await performStart();
|
|
802
819
|
console.log("[ChatInputArea] Re-focusing textarea (desktop only)");
|
|
803
820
|
setTimeout(() => {
|
|
804
|
-
var
|
|
805
|
-
return (
|
|
821
|
+
var _a2;
|
|
822
|
+
return (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
|
|
806
823
|
}, 0);
|
|
807
|
-
} else {
|
|
808
|
-
console.log("[ChatInputArea] SKIPPING textarea focus on mobile to prevent keyboard conflict");
|
|
809
|
-
if (document.activeElement instanceof HTMLElement) {
|
|
810
|
-
console.log("[ChatInputArea] Blur active element on mobile");
|
|
811
|
-
document.activeElement.blur();
|
|
812
|
-
}
|
|
813
824
|
}
|
|
814
825
|
};
|
|
815
826
|
const stopRecording = () => {
|
|
@@ -1022,6 +1033,10 @@ var TapToTalk = ({
|
|
|
1022
1033
|
const originalLog = console.log;
|
|
1023
1034
|
const originalWarn = console.warn;
|
|
1024
1035
|
const originalError = console.error;
|
|
1036
|
+
const formatTime = () => {
|
|
1037
|
+
const now = /* @__PURE__ */ new Date();
|
|
1038
|
+
return `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}.${now.getMilliseconds().toString().padStart(3, "0")}`;
|
|
1039
|
+
};
|
|
1025
1040
|
const addLog = (type, args) => {
|
|
1026
1041
|
try {
|
|
1027
1042
|
const msg = args.map((arg) => {
|
|
@@ -1029,7 +1044,7 @@ var TapToTalk = ({
|
|
|
1029
1044
|
if (typeof arg === "object") return JSON.stringify(arg);
|
|
1030
1045
|
return String(arg);
|
|
1031
1046
|
}).join(" ");
|
|
1032
|
-
setLogs((prev) => [`[${type}] ${msg}`, ...prev].slice(0, 50));
|
|
1047
|
+
setLogs((prev) => [`[${formatTime()}] [${type}] ${msg}`, ...prev].slice(0, 50));
|
|
1033
1048
|
} catch (e) {
|
|
1034
1049
|
}
|
|
1035
1050
|
};
|
|
@@ -1108,6 +1123,24 @@ var TapToTalk = ({
|
|
|
1108
1123
|
e.preventDefault();
|
|
1109
1124
|
e.stopPropagation();
|
|
1110
1125
|
}
|
|
1126
|
+
const now = Date.now();
|
|
1127
|
+
if (now - tapCountRef.current.lastTap < 500) {
|
|
1128
|
+
tapCountRef.current.count++;
|
|
1129
|
+
} else {
|
|
1130
|
+
tapCountRef.current.count = 1;
|
|
1131
|
+
}
|
|
1132
|
+
tapCountRef.current.lastTap = now;
|
|
1133
|
+
if (tapCountRef.current.count >= 5) {
|
|
1134
|
+
setShowDebug((prev) => !prev);
|
|
1135
|
+
tapCountRef.current.count = 0;
|
|
1136
|
+
if (isActive) {
|
|
1137
|
+
console.log("[TapToTalk] Debug trigger force-stop");
|
|
1138
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") nativeSpeech.stop();
|
|
1139
|
+
else customRecorder.stop();
|
|
1140
|
+
setVoiceTrigger(null);
|
|
1141
|
+
}
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1111
1144
|
console.log("[TapToTalk] toggleVoice called. isMobile:", isMobile());
|
|
1112
1145
|
if (processingRef.current) {
|
|
1113
1146
|
console.log("[TapToTalk] toggleVoice ignored - processing");
|
|
@@ -1116,24 +1149,6 @@ var TapToTalk = ({
|
|
|
1116
1149
|
processingRef.current = true;
|
|
1117
1150
|
console.log("[TapToTalk] toggleVoice called. isActive:", isActive, "isListening:", isListening, "isTranscribing:", isTranscribing);
|
|
1118
1151
|
try {
|
|
1119
|
-
const now = Date.now();
|
|
1120
|
-
if (now - tapCountRef.current.lastTap < 500) {
|
|
1121
|
-
tapCountRef.current.count++;
|
|
1122
|
-
} else {
|
|
1123
|
-
tapCountRef.current.count = 1;
|
|
1124
|
-
}
|
|
1125
|
-
tapCountRef.current.lastTap = now;
|
|
1126
|
-
if (tapCountRef.current.count >= 5) {
|
|
1127
|
-
setShowDebug((prev) => !prev);
|
|
1128
|
-
tapCountRef.current.count = 0;
|
|
1129
|
-
if (isActive) {
|
|
1130
|
-
console.log("[TapToTalk] Debug trigger force-stop");
|
|
1131
|
-
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") nativeSpeech.stop();
|
|
1132
|
-
else customRecorder.stop();
|
|
1133
|
-
setVoiceTrigger(null);
|
|
1134
|
-
}
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
1152
|
if (isActive) {
|
|
1138
1153
|
if (isTranscribing && !isListening) {
|
|
1139
1154
|
console.log("[TapToTalk] Ignoring click during transcription");
|
|
@@ -1149,41 +1164,47 @@ var TapToTalk = ({
|
|
|
1149
1164
|
} else {
|
|
1150
1165
|
console.log("[TapToTalk] Starting voice... mode:", voiceConfig == null ? void 0 : voiceConfig.mode);
|
|
1151
1166
|
setErrorMsg(null);
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1167
|
+
const performStart = async () => {
|
|
1168
|
+
setVoiceTrigger("click");
|
|
1169
|
+
console.log("[TapToTalk] voiceTrigger set to click");
|
|
1170
|
+
if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "custom") {
|
|
1171
|
+
console.log("[TapToTalk] Starting custom recorder...");
|
|
1172
|
+
try {
|
|
1173
|
+
await customRecorder.start();
|
|
1174
|
+
console.log("[TapToTalk] Custom recorder started successfully");
|
|
1175
|
+
} catch (e2) {
|
|
1176
|
+
console.error("[TapToTalk] Custom recorder failed:", e2);
|
|
1177
|
+
setErrorMsg("Mic access denied");
|
|
1178
|
+
setVoiceTrigger(null);
|
|
1179
|
+
}
|
|
1180
|
+
} else {
|
|
1181
|
+
console.log("[TapToTalk] Starting native speech recognition...");
|
|
1182
|
+
if (!nativeSpeech.isSupported) {
|
|
1183
|
+
console.error("[TapToTalk] Native speech not supported");
|
|
1184
|
+
setErrorMsg("Speech not supported");
|
|
1185
|
+
setVoiceTrigger(null);
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
console.log("[TapToTalk] Calling nativeSpeech.start()...");
|
|
1189
|
+
nativeSpeech.start();
|
|
1190
|
+
console.log("[TapToTalk] nativeSpeech.start() called");
|
|
1158
1191
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1192
|
+
};
|
|
1193
|
+
if (isMobile()) {
|
|
1194
|
+
console.log("[TapToTalk] Mobile: Blurring active element and skipping onFocusTarget");
|
|
1195
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
1161
1196
|
document.activeElement.blur();
|
|
1162
1197
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
console.log("[TapToTalk] Starting custom recorder...");
|
|
1168
|
-
try {
|
|
1169
|
-
await customRecorder.start();
|
|
1170
|
-
console.log("[TapToTalk] Custom recorder started successfully");
|
|
1171
|
-
} catch (e2) {
|
|
1172
|
-
console.error("[TapToTalk] Custom recorder failed:", e2);
|
|
1173
|
-
setErrorMsg("Mic access denied");
|
|
1174
|
-
setVoiceTrigger(null);
|
|
1175
|
-
}
|
|
1198
|
+
console.log("[TapToTalk] Mobile: Waiting 300ms before starting recognition...");
|
|
1199
|
+
setTimeout(() => {
|
|
1200
|
+
performStart();
|
|
1201
|
+
}, 300);
|
|
1176
1202
|
} else {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
setErrorMsg("Speech not supported");
|
|
1181
|
-
setVoiceTrigger(null);
|
|
1182
|
-
return;
|
|
1203
|
+
if (onFocusTarget) {
|
|
1204
|
+
console.log("[TapToTalk] Desktop: calling onFocusTarget()");
|
|
1205
|
+
onFocusTarget();
|
|
1183
1206
|
}
|
|
1184
|
-
|
|
1185
|
-
nativeSpeech.start();
|
|
1186
|
-
console.log("[TapToTalk] nativeSpeech.start() called");
|
|
1207
|
+
performStart();
|
|
1187
1208
|
}
|
|
1188
1209
|
}
|
|
1189
1210
|
} finally {
|