@todoforai/voiceloop 0.1.16 → 0.1.17

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": "@todoforai/voiceloop",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Fast, interruptible browser voice agent: VAD → STT → LLM → TTS with real barge-in, echo filtering, streaming first-sentence TTS and tap-to-seek. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -47,9 +47,10 @@ registerProcessor('capture-processor', class extends AudioWorkletProcessor {
47
47
  return true;
48
48
  }
49
49
  });`;
50
- const CAPTURE_WORKLET_URL = typeof URL !== 'undefined' && URL.createObjectURL
51
- ? URL.createObjectURL(new Blob([CAPTURE_WORKLET_SRC], { type: 'text/javascript' }))
52
- : '';
50
+ // Built lazily: React Native ships a URL.createObjectURL that throws ("not implemented"), and a
51
+ // native host (audioIO) never loads the worklet at all — so nothing may run at import time.
52
+ let captureWorkletUrl = null;
53
+ const CAPTURE_WORKLET_URL_GET = () => captureWorkletUrl ??= URL.createObjectURL(new Blob([CAPTURE_WORKLET_SRC], { type: 'text/javascript' }));
53
54
 
54
55
  // Compose the full system prompt: a persona (base voice persona by default, or a host-supplied one)
55
56
  // + the host's conversation context (if any).
@@ -438,7 +439,7 @@ export class VoiceAgent {
438
439
  try {
439
440
  ctx = new AudioContext({ sampleRate: 16000 });
440
441
  const src = ctx.createMediaStreamSource(stream);
441
- await ctx.audioWorklet.addModule(CAPTURE_WORKLET_URL);
442
+ await ctx.audioWorklet.addModule(CAPTURE_WORKLET_URL_GET());
442
443
  if (gen !== this._pipelineGen || this._closed) { stream.getTracks().forEach(t => t.stop()); ctx.close(); return; } // superseded/stopped while loading
443
444
  const node = new AudioWorkletNode(ctx, 'capture-processor');
444
445
  node.port.onmessage = e => this._onCapture(e.data); // Float32Array chunk from the audio thread