@contentgrowth/llm-service 0.9.95 → 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,63 @@ 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
- if (isMobile()) {
766
- console.log("[ChatInputArea] SKIPPING textarea focus on mobile to prevent keyboard conflict");
767
- if (document.activeElement instanceof HTMLElement) {
768
- console.log("[ChatInputArea] Blur active element on mobile BEFORE start");
769
- document.activeElement.blur();
770
- }
771
- }
772
768
  if (voiceTrigger || isTranscribing) {
773
769
  console.log("[ChatInputArea] startRecording ignored - already active");
774
770
  return;
775
771
  }
776
- setVoiceTrigger(trigger);
777
- setVoiceError(null);
778
- if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "native") {
779
- console.log("[ChatInputArea] Using native speech recognition");
780
- if (!nativeSpeech.isSupported) {
781
- console.error("[ChatInputArea] Native speech not supported");
782
- alert("Speech recognition is not supported in this browser.");
783
- setVoiceTrigger(null);
784
- return;
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");
785
805
  }
786
- console.log("[ChatInputArea] Calling nativeSpeech.start()...");
787
- nativeSpeech.start();
788
- console.log("[ChatInputArea] nativeSpeech.start() called");
789
- console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (after nativeSpeech.start)...");
790
- try {
791
- (_a2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _a2.call(voiceConfig);
792
- console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
793
- } catch (e) {
794
- 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();
795
812
  }
813
+ console.log("[ChatInputArea] Mobile: Waiting 300ms before starting recognition...");
814
+ setTimeout(() => {
815
+ performStart();
816
+ }, 300);
796
817
  } else {
797
- console.log("[ChatInputArea] Using custom recorder");
798
- console.log("[ChatInputArea] Calling voiceConfig.onVoiceStart if exists (custom mode)...");
799
- try {
800
- (_b2 = voiceConfig == null ? void 0 : voiceConfig.onVoiceStart) == null ? void 0 : _b2.call(voiceConfig);
801
- console.log("[ChatInputArea] voiceConfig.onVoiceStart completed");
802
- } catch (e) {
803
- console.error("[ChatInputArea] voiceConfig.onVoiceStart threw error", e);
804
- }
805
- await customRecorder.start();
806
- console.log("[ChatInputArea] Custom recorder started");
807
- }
808
- if (!isMobile()) {
818
+ await performStart();
809
819
  console.log("[ChatInputArea] Re-focusing textarea (desktop only)");
810
820
  setTimeout(() => {
811
- var _a3;
812
- return (_a3 = textareaRef.current) == null ? void 0 : _a3.focus();
821
+ var _a2;
822
+ return (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
813
823
  }, 0);
814
824
  }
815
825
  };
@@ -1023,6 +1033,10 @@ var TapToTalk = ({
1023
1033
  const originalLog = console.log;
1024
1034
  const originalWarn = console.warn;
1025
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
+ };
1026
1040
  const addLog = (type, args) => {
1027
1041
  try {
1028
1042
  const msg = args.map((arg) => {
@@ -1030,7 +1044,7 @@ var TapToTalk = ({
1030
1044
  if (typeof arg === "object") return JSON.stringify(arg);
1031
1045
  return String(arg);
1032
1046
  }).join(" ");
1033
- setLogs((prev) => [`[${type}] ${msg}`, ...prev].slice(0, 50));
1047
+ setLogs((prev) => [`[${formatTime()}] [${type}] ${msg}`, ...prev].slice(0, 50));
1034
1048
  } catch (e) {
1035
1049
  }
1036
1050
  };
@@ -1150,38 +1164,47 @@ var TapToTalk = ({
1150
1164
  } else {
1151
1165
  console.log("[TapToTalk] Starting voice... mode:", voiceConfig == null ? void 0 : voiceConfig.mode);
1152
1166
  setErrorMsg(null);
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");
1191
+ }
1192
+ };
1153
1193
  if (isMobile()) {
1154
1194
  console.log("[TapToTalk] Mobile: Blurring active element and skipping onFocusTarget");
1155
1195
  if (document.activeElement instanceof HTMLElement) {
1156
1196
  document.activeElement.blur();
1157
1197
  }
1158
- } else if (onFocusTarget) {
1159
- console.log("[TapToTalk] Desktop: calling onFocusTarget()");
1160
- onFocusTarget();
1161
- }
1162
- setVoiceTrigger("click");
1163
- console.log("[TapToTalk] voiceTrigger set to click");
1164
- if ((voiceConfig == null ? void 0 : voiceConfig.mode) === "custom") {
1165
- console.log("[TapToTalk] Starting custom recorder...");
1166
- try {
1167
- await customRecorder.start();
1168
- console.log("[TapToTalk] Custom recorder started successfully");
1169
- } catch (e2) {
1170
- console.error("[TapToTalk] Custom recorder failed:", e2);
1171
- setErrorMsg("Mic access denied");
1172
- setVoiceTrigger(null);
1173
- }
1198
+ console.log("[TapToTalk] Mobile: Waiting 300ms before starting recognition...");
1199
+ setTimeout(() => {
1200
+ performStart();
1201
+ }, 300);
1174
1202
  } else {
1175
- console.log("[TapToTalk] Starting native speech recognition...");
1176
- if (!nativeSpeech.isSupported) {
1177
- console.error("[TapToTalk] Native speech not supported");
1178
- setErrorMsg("Speech not supported");
1179
- setVoiceTrigger(null);
1180
- return;
1203
+ if (onFocusTarget) {
1204
+ console.log("[TapToTalk] Desktop: calling onFocusTarget()");
1205
+ onFocusTarget();
1181
1206
  }
1182
- console.log("[TapToTalk] Calling nativeSpeech.start()...");
1183
- nativeSpeech.start();
1184
- console.log("[TapToTalk] nativeSpeech.start() called");
1207
+ performStart();
1185
1208
  }
1186
1209
  }
1187
1210
  } finally {