@absolutejs/voice 0.0.22-beta.645 → 0.0.22-beta.646

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,6 +1,8 @@
1
1
  export { bindVoiceReactiveSource, voiceSseReactiveSource, } from "./reactiveSource";
2
2
  export type { VoiceReactiveSource, VoiceSseReactiveSourceOptions, } from "./reactiveSource";
3
3
  export { createVoiceConnection } from "./connection";
4
+ export { checkBrowserVoiceSupport, probeBrowserVoiceSupport, } from "./browserVoiceSupport";
5
+ export type { BrowserVoiceSupportProbe, BrowserVoiceSupportReport, } from "./browserVoiceSupport";
4
6
  export { createVoiceAudioPlayer, decodeVoiceAudioChunk } from "./audioPlayer";
5
7
  export { createTimeStretcher, type TimeStretcher } from "./timeStretch";
6
8
  export { createVoiceStream } from "./createVoiceStream";
@@ -375,6 +375,88 @@ var createVoiceConnection = (path, options = {}) => {
375
375
  getSessionId: () => state.sessionId
376
376
  };
377
377
  };
378
+ // src/client/browserVoiceSupport.ts
379
+ var safeGet = (fn) => {
380
+ try {
381
+ return fn();
382
+ } catch {
383
+ return;
384
+ }
385
+ };
386
+ var detectMediaRecorderOpus = (ctor) => {
387
+ if (!ctor || typeof ctor.isTypeSupported !== "function")
388
+ return false;
389
+ try {
390
+ return ctor.isTypeSupported("audio/webm;codecs=opus");
391
+ } catch {
392
+ return false;
393
+ }
394
+ };
395
+ var checkBrowserVoiceSupport = (globalScope = globalThis) => {
396
+ const capabilities = probeBrowserVoiceSupport(globalScope);
397
+ const blockers = [];
398
+ const warnings = [];
399
+ if (!capabilities.hasWebSocket) {
400
+ blockers.push("WebSocket is not available \u2014 voice runtime cannot stream audio.");
401
+ }
402
+ if (!capabilities.hasGetUserMedia) {
403
+ blockers.push("navigator.mediaDevices.getUserMedia is not available \u2014 cannot capture microphone.");
404
+ }
405
+ if (capabilities.isInsecureContext) {
406
+ blockers.push("Page is served from an insecure context; getUserMedia requires HTTPS or localhost.");
407
+ }
408
+ if (!capabilities.hasAudioContext) {
409
+ blockers.push("AudioContext is not available \u2014 cannot decode or play TTS audio.");
410
+ }
411
+ if (!capabilities.hasAudioWorklet) {
412
+ warnings.push("AudioWorklet is unavailable \u2014 noise suppression and custom audio processors won't run.");
413
+ }
414
+ if (!capabilities.hasRTCPeerConnection) {
415
+ warnings.push("RTCPeerConnection is unavailable \u2014 WebRTC transport paths are disabled.");
416
+ }
417
+ if (!capabilities.hasOpusEncoding) {
418
+ warnings.push("MediaRecorder does not advertise Opus support \u2014 fall back to PCM streaming.");
419
+ }
420
+ if (capabilities.requiresUserGestureToResumeAudio) {
421
+ warnings.push("Safari / iOS requires a user gesture before audioContext.resume() succeeds.");
422
+ }
423
+ return {
424
+ blockers,
425
+ capabilities,
426
+ ok: blockers.length === 0,
427
+ warnings
428
+ };
429
+ };
430
+ var probeBrowserVoiceSupport = (globalScope = globalThis) => {
431
+ const win = globalScope;
432
+ const userAgent = win.navigator?.userAgent ?? "";
433
+ const audioContextCtor = win.AudioContext ?? win.webkitAudioContext;
434
+ const hasAudioContext = typeof audioContextCtor === "function";
435
+ const hasAudioWorklet = hasAudioContext ? safeGet(() => ("audioWorklet" in audioContextCtor.prototype)) === true : false;
436
+ const hasGetUserMedia = Boolean(win.navigator?.mediaDevices && typeof win.navigator.mediaDevices.getUserMedia === "function");
437
+ const hasMediaRecorder = typeof win.MediaRecorder === "function";
438
+ const hasRTCPeerConnection = typeof win.RTCPeerConnection === "function";
439
+ const hasWebSocket = typeof win.WebSocket === "function";
440
+ const isInsecureContext = typeof win.isSecureContext === "boolean" ? !win.isSecureContext : false;
441
+ const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
442
+ const isIos = /iPad|iPhone|iPod/.test(userAgent);
443
+ const requiresUserGestureToResumeAudio = isSafari || isIos;
444
+ const hasOpusEncoding = detectMediaRecorderOpus(win.MediaRecorder);
445
+ return {
446
+ hasAudioContext,
447
+ hasAudioWorklet,
448
+ hasGetUserMedia,
449
+ hasMediaRecorder,
450
+ hasOpusEncoding,
451
+ hasRTCPeerConnection,
452
+ hasWebSocket,
453
+ isInsecureContext,
454
+ isIos,
455
+ isSafari,
456
+ requiresUserGestureToResumeAudio,
457
+ userAgent
458
+ };
459
+ };
378
460
  // src/client/timeStretch.ts
379
461
  var HOP_MS = 10;
380
462
  var SEEK_MS = 5;
@@ -12464,6 +12546,7 @@ export {
12464
12546
  renderVoiceCallDebuggerLaunchHTML,
12465
12547
  renderVoiceAgentSquadStatusHTML,
12466
12548
  recordVoiceOpsActionResult,
12549
+ probeBrowserVoiceSupport,
12467
12550
  postVoiceLiveOpsAction,
12468
12551
  mountVoiceTurnQuality,
12469
12552
  mountVoiceTurnLatency,
@@ -12609,6 +12692,7 @@ export {
12609
12692
  createVoiceAgentSquadStatusStore,
12610
12693
  createTimeStretcher,
12611
12694
  createMicrophoneCapture,
12695
+ checkBrowserVoiceSupport,
12612
12696
  buildVoiceAgentSquadStatusReport,
12613
12697
  bindVoiceReactiveSource,
12614
12698
  bindVoiceProviderSimulationControls,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.645",
3
+ "version": "0.0.22-beta.646",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",