onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.88k stars 700 forks source link

The usage example doesn't work #1036

Closed tobias-silva closed 1 year ago

tobias-silva commented 1 year ago

Describe the bug I'm trying to use the example provided in the readme

import { Web } from "./sip.js";

// Helper function to get an HTML audio element
function getAudioElement(id: string): HTMLAudioElement {
  const el = document.getElementById(id);
  if (!(el instanceof HTMLAudioElement)) {
    throw new Error(`Element "${id}" not found or not an audio element.`);
  }
  return el;
}

// Options for SimpleUser
const options: Web.SimpleUserOptions = {
  aor: "sip:alice@example.com", // caller
  media: {
    constraints: { audio: true, video: false }, // audio only call
    remote: { audio: getAudioElement("remoteAudio") } // play remote audio
  }
};

// WebSocket server to connect with
const server = "wss://sip.example.com";

// Construct a SimpleUser instance
const simpleUser = new Web.SimpleUser(server, options);

// Connect to server and place call
simpleUser.connect()
  .then(() => simpleUser.call("sip:bob@example.com"))
  .catch((error: Error) => {
    // Call failed
  });

Observed behavior I get a error in the Firefox console

Uncaught SyntaxError: ambiguous indirect export: Web

and in Chrome

caught SyntaxError: The requested module './sip.js' does not provide an export named 'Web' (at test.js:1:10)

Environment Information

I'm doing something wrong or there's a bug?