@olares/lares-mobile 0.15.37 → 0.15.39

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olares/lares-mobile",
3
- "version": "0.15.37",
3
+ "version": "0.15.39",
4
4
  "description": "Lares chat component for LarePass",
5
5
  "type": "module",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "vue": "^3.2.0"
29
29
  },
30
30
  "dependencies": {
31
- "@olares/lares-core": "0.15.37",
31
+ "@olares/lares-core": "0.15.39",
32
32
  "markdown-it": "^14.3.0"
33
33
  }
34
34
  }
package/src/App.vue CHANGED
@@ -135,6 +135,7 @@ import { playAudioStream, createStreamingCapture } from "@olares/lares-core/voic
135
135
  import { voiceHeaders, wavBlob } from "@olares/lares-core/voice/client";
136
136
  import { browserPlays } from "@olares/lares-core/voice/playback";
137
137
  import { speakProblemText, speakToggleNotice } from "@olares/lares-core/voice/problem";
138
+ import { voiceVisibleError } from "@olares/lares-core/voice/presentation";
138
139
  import { appendDraftMentions } from "@olares/lares-core/files/mention";
139
140
  import { FileIntake, partitionDocumentsBySize, splitComposerFiles } from "@olares/lares-core/files/intake";
140
141
  import {
@@ -597,7 +598,7 @@ export default {
597
598
  this.voicePanelUnsub = this.voicePanel.subscribe(() => {
598
599
  const view = this.voicePanel.getSnapshot(); this.voicePanelState = view;
599
600
  this.voiceCall = view.snapshot?.connection === "closed" ? null : view.snapshot;
600
- this.voicePhase = view.snapshot?.capture || "idle"; this.voiceError = view.error || view.snapshot?.error || "";
601
+ this.voicePhase = view.snapshot?.capture || "idle"; this.voiceError = voiceVisibleError(view) || "";
601
602
  // The call no longer owns the answer: a cancelled take gives it back.
602
603
  if (this.voiceSuspended && view.snapshot?.connection !== "open") this.resumeSuspendedReadout();
603
604
  });
@@ -1,6 +1,32 @@
1
1
  import { primePlaybackContext } from "@olares/lares-core/voice/pcm-player";
2
2
 
3
- const SILENT_WAV = "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQAAAAA=";
3
+ /**
4
+ * 16-bit silence at the playback clock. iOS keeps one hardware rate; the old
5
+ * 8 kHz unlock left the iPhone speaker resampling the readout into a buzz.
6
+ */
7
+ function unlockClip(sampleRate) {
8
+ const rate = Number.isInteger(sampleRate) && sampleRate >= 8000 && sampleRate <= 192000 ? sampleRate : 48000;
9
+ const dataBytes = 128 * 2;
10
+ const bytes = new Uint8Array(44 + dataBytes);
11
+ const view = new DataView(bytes.buffer);
12
+ const text = (offset, value) => { for (let i = 0; i < value.length; i += 1) view.setUint8(offset + i, value.charCodeAt(i)); };
13
+ text(0, "RIFF");
14
+ view.setUint32(4, 36 + dataBytes, true);
15
+ text(8, "WAVE");
16
+ text(12, "fmt ");
17
+ view.setUint32(16, 16, true);
18
+ view.setUint16(20, 1, true);
19
+ view.setUint16(22, 1, true);
20
+ view.setUint32(24, rate, true);
21
+ view.setUint32(28, rate * 2, true);
22
+ view.setUint16(32, 2, true);
23
+ view.setUint16(34, 16, true);
24
+ text(36, "data");
25
+ view.setUint32(40, dataBytes, true);
26
+ let binary = "";
27
+ for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
28
+ return `data:audio/wav;base64,${btoa(binary)}`;
29
+ }
4
30
 
5
31
  /**
6
32
  * One element, unlocked inside the gesture that asks the question (a voice
@@ -22,9 +48,9 @@ export function createAnswerPlayer() {
22
48
  };
23
49
  return {
24
50
  unlock() {
25
- primePlaybackContext();
51
+ const context = primePlaybackContext();
26
52
  if (!audio || !audio.paused) return;
27
- audio.src = SILENT_WAV;
53
+ audio.src = unlockClip(context?.sampleRate);
28
54
  void audio.play().catch(() => {});
29
55
  },
30
56
  /** Resolves when the clip ends (true), or is stopped or fails (false). */