@myned-ai/avatar-chat-widget 0.5.0 → 0.6.0

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.
@@ -1180,6 +1180,10 @@ class AudioInput {
1180
1180
  // 100ms at 24kHz
1181
1181
  async requestPermission() {
1182
1182
  try {
1183
+ if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
1184
+ log$e.error("MediaDevices API not available. Microphone requires HTTPS.");
1185
+ throw new Error("Microphone requires a secure connection (HTTPS)");
1186
+ }
1183
1187
  const stream = await navigator.mediaDevices.getUserMedia({
1184
1188
  audio: {
1185
1189
  sampleRate: CONFIG.audio.input.sampleRate,
@@ -1225,6 +1229,9 @@ class AudioInput {
1225
1229
  */
1226
1230
  async startPCM16Recording(onData) {
1227
1231
  try {
1232
+ if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
1233
+ throw new Error("Microphone requires a secure connection (HTTPS)");
1234
+ }
1228
1235
  this.mediaStream = await navigator.mediaDevices.getUserMedia({
1229
1236
  audio: {
1230
1237
  channelCount: 1,
@@ -3551,6 +3558,12 @@ class VoiceInputController {
3551
3558
  * Start voice recording
3552
3559
  */
3553
3560
  async start() {
3561
+ if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
3562
+ const message = "Voice input requires a secure connection (HTTPS). Please use text input instead.";
3563
+ log$5.warn(message);
3564
+ alert(message);
3565
+ return;
3566
+ }
3554
3567
  try {
3555
3568
  log$5.info("Starting recording (PCM16 24kHz)");
3556
3569
  this.protocolClient.sendAudioStreamStart();
@@ -3569,7 +3582,10 @@ class VoiceInputController {
3569
3582
  log$5.error("Failed to start recording:", error2);
3570
3583
  errorBoundary.handleError(error2, "audio-input");
3571
3584
  this.options.onError?.(error2);
3572
- alert("Microphone access denied. Please enable microphone permissions.");
3585
+ const errorMsg = error2.message || "";
3586
+ if (errorMsg.includes("Permission denied") || errorMsg.includes("NotAllowedError")) {
3587
+ alert("Microphone access was denied. Please allow microphone access in your browser settings to use voice input.");
3588
+ }
3573
3589
  }
3574
3590
  }
3575
3591
  /**
@@ -3696,7 +3712,6 @@ class ChatManager {
3696
3712
  await this.protocolClient.connect();
3697
3713
  log$4.info("WebSocket connected");
3698
3714
  this.avatar.setChatState("Idle");
3699
- await this.audioInput.requestPermission();
3700
3715
  } catch (error2) {
3701
3716
  errorBoundary.handleError(error2, "chat-manager");
3702
3717
  log$4.error("Connection failed");
@@ -3788,6 +3803,9 @@ class ChatManager {
3788
3803
  this.useSyncPlayback = false;
3789
3804
  this.subtitleController.showRemaining();
3790
3805
  this.transcriptManager.finalizeAssistantTurn();
3806
+ setTimeout(() => {
3807
+ this.subtitleController.clear();
3808
+ }, 1500);
3791
3809
  });
3792
3810
  }
3793
3811
  setupAutoScroll() {
@@ -4286,8 +4304,10 @@ const WIDGET_STYLES = `
4286
4304
  @media (max-width: 480px) {
4287
4305
  .widget-root {
4288
4306
  width: 100vw;
4289
- height: 100vh;
4307
+ height: 100vh; /* Fallback for older browsers */
4308
+ height: 100dvh; /* Dynamic viewport height - accounts for mobile browser UI */
4290
4309
  max-height: 100vh;
4310
+ max-height: 100dvh;
4291
4311
  border-radius: 0;
4292
4312
  /* Let the mobile media query at the bottom handle the rest */
4293
4313
  padding-bottom: 90px; /* Ensure input layer space is preserved */
@@ -5336,7 +5356,8 @@ const WIDGET_STYLES = `
5336
5356
 
5337
5357
  /* Avatar-focus mode on mobile: avatar takes most of the space */
5338
5358
  :host(:not(.collapsed)) [data-drawer-state="avatar-focus"] {
5339
- --avatar-height: calc(100vh - 56px - 90px) !important; /* Full height minus header and input */
5359
+ --avatar-height: calc(100vh - 56px - 90px) !important; /* Fallback */
5360
+ --avatar-height: calc(100dvh - 56px - 90px) !important; /* Full height minus header and input */
5340
5361
  background: transparent !important; /* Let avatar stage show through */
5341
5362
  }
5342
5363
 
@@ -5381,11 +5402,13 @@ const WIDGET_STYLES = `
5381
5402
 
5382
5403
  /* Text-focus mode on mobile: chat takes most of the space, avatar in corner */
5383
5404
  :host(:not(.collapsed)) [data-drawer-state="text-focus"] {
5384
- --chat-height: calc(100vh - 70px - 90px) !important; /* Full height minus header and input */
5405
+ --chat-height: calc(100vh - 70px - 90px) !important; /* Fallback */
5406
+ --chat-height: calc(100dvh - 70px - 90px) !important; /* Full height minus header and input */
5385
5407
  }
5386
5408
 
5387
5409
  :host(:not(.collapsed)) [data-drawer-state="text-focus"] .chat-section {
5388
- height: calc(100vh - 70px - 90px) !important;
5410
+ height: calc(100vh - 70px - 90px) !important; /* Fallback */
5411
+ height: calc(100dvh - 70px - 90px) !important;
5389
5412
  flex: 1;
5390
5413
  }
5391
5414