@rapidaai/react 1.1.45 → 1.1.46

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.
@@ -1,4 +1,4 @@
1
- export { ei as DeviceSelectorComponent } from '../device-selector-D7AEGpZu.mjs';
1
+ export { ei as DeviceSelectorComponent } from '../device-selector-CoAQBhd-.mjs';
2
2
  import 'react';
3
3
  import 'google-protobuf';
4
4
  import 'google-protobuf/google/protobuf/any_pb';
@@ -1,4 +1,4 @@
1
- export { ei as DeviceSelectorComponent } from '../device-selector-D7AEGpZu.js';
1
+ export { ei as DeviceSelectorComponent } from '../device-selector-CoAQBhd-.js';
2
2
  import 'react';
3
3
  import 'google-protobuf';
4
4
  import 'google-protobuf/google/protobuf/any_pb';
@@ -28613,9 +28613,7 @@ var VoiceAgent = class extends Agent {
28613
28613
  };
28614
28614
  connectDevice = async () => {
28615
28615
  try {
28616
- this.preliminaryInputStream = await navigator.mediaDevices.getUserMedia({
28617
- audio: true
28618
- });
28616
+ this.preliminaryInputStream = await this.waitForUserMediaPermission();
28619
28617
  [this.input, this.output] = await Promise.all([
28620
28618
  Input.create(this.agentConfig.inputOptions.recorderOption),
28621
28619
  Output.create(this.agentConfig.outputOptions.playerOption)
@@ -28626,7 +28624,19 @@ var VoiceAgent = class extends Agent {
28626
28624
  this.preliminaryInputStream = null;
28627
28625
  } catch (error) {
28628
28626
  await this.disconnectAudio();
28629
- console.log(error);
28627
+ console.error("Microphone permission error:", error);
28628
+ }
28629
+ };
28630
+ // Helper method to handle media permissions:
28631
+ waitForUserMediaPermission = async () => {
28632
+ try {
28633
+ return await navigator.mediaDevices.getUserMedia({ audio: true });
28634
+ } catch (error) {
28635
+ console.error(
28636
+ "Permission denied or error while requesting microphone access:",
28637
+ error
28638
+ );
28639
+ throw error;
28630
28640
  }
28631
28641
  };
28632
28642
  /**
@@ -28673,7 +28683,6 @@ var VoiceAgent = class extends Agent {
28673
28683
  console.log("Please call connect first, agent is not connected");
28674
28684
  return;
28675
28685
  }
28676
- const maxVolume = event.data[1];
28677
28686
  if (this.inputChannel == "audio" /* Audio */)
28678
28687
  this.talkingConnection?.write(
28679
28688
  this.createAssistantAudioMessage(
@@ -28739,10 +28748,10 @@ var VoiceAgent = class extends Agent {
28739
28748
  */
28740
28749
  connect = async () => {
28741
28750
  try {
28742
- await this.connectAgent();
28743
28751
  if (this.inputChannel == "audio" /* Audio */) {
28744
28752
  await this.connectAudio();
28745
28753
  }
28754
+ await this.connectAgent();
28746
28755
  } catch (err) {
28747
28756
  console.error("error while connect " + err);
28748
28757
  }