@avaturn-live/web-sdk 0.0.21 → 0.0.22

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/dist/main.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare class AvaturnHead implements IAvaturnHead {
5
5
  inited: boolean;
6
6
  mediaStream: MediaStream;
7
7
  session_id: string;
8
+ protected abortController: AbortController;
8
9
  protected timeout: ReturnType<typeof setTimeout> | 0;
9
10
  protected keepAlive: boolean;
10
11
  protected fetcher: Axios;
@@ -12,6 +13,12 @@ export declare class AvaturnHead implements IAvaturnHead {
12
13
  protected handlers: {
13
14
  [K in AvaturnHeadEvent]?: AvaturnEventCallback<K>[];
14
15
  };
16
+ /**
17
+ * AvaturnHead main class
18
+ *
19
+ * @constructor
20
+ * @param {AvaturnHeadConfig} config - The configuration object for Avaturn Head.
21
+ */
15
22
  constructor({ apiHost, sessionToken, preloadBundle, preconnect, keepAlive, }: AvaturnHeadConfig);
16
23
  protected startIdleTimeout(): void;
17
24
  protected restartIdleTimeout(): void;
package/dist/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var Xo = Object.defineProperty;
2
2
  var Zo = (t, e, n) => e in t ? Xo(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var re = (t, e, n) => Zo(t, typeof e != "symbol" ? e + "" : e, n);
3
+ var Z = (t, e, n) => Zo(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  function Gr(t, e) {
5
5
  if (t == null) return {};
6
6
  var n, r, i = function(a, c) {
@@ -1989,7 +1989,7 @@ function ki(t) {
1989
1989
  const e = rn(), n = Yn(e);
1990
1990
  return to(e, t), n;
1991
1991
  }
1992
- function ee() {
1992
+ function te() {
1993
1993
  const t = rn();
1994
1994
  if (t.__SENTRY__ && t.__SENTRY__.acs) {
1995
1995
  const e = t.__SENTRY__.acs.getCurrentHub();
@@ -2025,7 +2025,7 @@ function Aa(t, e, n, r) {
2025
2025
  }
2026
2026
  const Ei = [];
2027
2027
  function Ti(t, e) {
2028
- e[t.name] = t, Ei.indexOf(t.name) === -1 && (t.setupOnce(Zs, ee), Ei.push(t.name), (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && R.log(`Integration installed: ${t.name}`));
2028
+ e[t.name] = t, Ei.indexOf(t.name) === -1 && (t.setupOnce(Zs, te), Ei.push(t.name), (typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__) && R.log(`Integration installed: ${t.name}`));
2029
2029
  }
2030
2030
  function Ra(t, e, n, r) {
2031
2031
  const { normalizeDepth: i = 3, normalizeMaxBreadth: s = 1e3 } = t, a = { ...e, event_id: e.event_id || n.event_id || xe(), timestamp: e.timestamp || pn() }, c = n.integrations || t.integrations.map((h) => h.name);
@@ -2048,8 +2048,8 @@ function Ra(t, e, n, r) {
2048
2048
  let B;
2049
2049
  const L = k.get(M);
2050
2050
  L ? B = L : (B = f(M), k.set(M, B));
2051
- for (let te = B.length - 1; te >= 0; te--) {
2052
- const Ne = B[te];
2051
+ for (let ne = B.length - 1; ne >= 0; ne--) {
2052
+ const Ne = B[ne];
2053
2053
  if (Ne.filename) {
2054
2054
  T[Ne.filename] = _[M];
2055
2055
  break;
@@ -2508,8 +2508,8 @@ function ct(t, e = {}, n) {
2508
2508
  Wn--;
2509
2509
  }), s = (c) => {
2510
2510
  var l, p;
2511
- c.addEventProcessor((h) => (e.mechanism && ($n(h, void 0), kt(h, e.mechanism)), h.extra = { ...h.extra, arguments: i }, h)), l = a, ee().captureException(l, { captureContext: p });
2512
- }, ee().withScope(s), a;
2511
+ c.addEventProcessor((h) => (e.mechanism && ($n(h, void 0), kt(h, e.mechanism)), h.extra = { ...h.extra, arguments: i }, h)), l = a, te().captureException(l, { captureContext: p });
2512
+ }, te().withScope(s), a;
2513
2513
  }
2514
2514
  var s;
2515
2515
  };
@@ -2564,7 +2564,7 @@ function Sr(t, e, n, r, i) {
2564
2564
  return "code" in a && (s.tags = { ...s.tags, "DOMException.code": `${a.code}` }), s;
2565
2565
  }
2566
2566
  return Js(e) ? Tn(t, e) : ot(e) || Zt(e) ? (s = function(a, c, l, p) {
2567
- const h = ee().getClient(), f = h && h.getOptions().normalizeDepth, _ = { exception: { values: [{ type: Zt(c) ? c.constructor.name : p ? "UnhandledRejection" : "Error", value: Fa(c, { isUnhandledRejection: p }) }] }, extra: { __serialized__: Ys(c, f) } };
2567
+ const h = te().getClient(), f = h && h.getOptions().normalizeDepth, _ = { exception: { values: [{ type: Zt(c) ? c.constructor.name : p ? "UnhandledRejection" : "Error", value: Fa(c, { isUnhandledRejection: p }) }] }, extra: { __serialized__: Ys(c, f) } };
2568
2568
  if (l) {
2569
2569
  const k = wr(a, l);
2570
2570
  k.length && (_.exception.values[0].stacktrace = { frames: k });
@@ -2623,13 +2623,13 @@ class Ct {
2623
2623
  } catch {
2624
2624
  i = "<unknown>";
2625
2625
  }
2626
- i.length !== 0 && ee().addBreadcrumb({ category: `ui.${r.name}`, message: i }, { event: r.event, name: r.name, global: r.global });
2626
+ i.length !== 0 && te().addBreadcrumb({ category: `ui.${r.name}`, message: i }, { event: r.event, name: r.name, global: r.global });
2627
2627
  }
2628
2628
  return n;
2629
2629
  }(this.options.dom)), this.options.xhr && Ue("xhr", qa), this.options.fetch && Ue("fetch", Ja), this.options.history && Ue("history", Va);
2630
2630
  }
2631
2631
  addSentryBreadcrumb(e) {
2632
- this.options.sentry && ee().addBreadcrumb({ category: "sentry." + (e.type === "transaction" ? "transaction" : "event"), event_id: e.event_id, level: e.level, message: Ae(e) }, { event: e });
2632
+ this.options.sentry && te().addBreadcrumb({ category: "sentry." + (e.type === "transaction" ? "transaction" : "event"), event_id: e.event_id, level: e.level, message: Ae(e) }, { event: e });
2633
2633
  }
2634
2634
  }
2635
2635
  function Ua(t) {
@@ -2643,22 +2643,22 @@ function Ua(t) {
2643
2643
  if (t.args[0] !== !1) return;
2644
2644
  e.message = `Assertion failed: ${ai(t.args.slice(1), " ") || "console.assert"}`, e.data.arguments = t.args.slice(1);
2645
2645
  }
2646
- ee().addBreadcrumb(e, { input: t.args, level: t.level });
2646
+ te().addBreadcrumb(e, { input: t.args, level: t.level });
2647
2647
  }
2648
2648
  function qa(t) {
2649
2649
  const { startTimestamp: e, endTimestamp: n } = t, r = t.xhr[vt];
2650
2650
  if (!e || !n || !r) return;
2651
2651
  const { method: i, url: s, status_code: a, body: c } = r, l = { method: i, url: s, status_code: a }, p = { xhr: t.xhr, input: c, startTimestamp: e, endTimestamp: n };
2652
- ee().addBreadcrumb({ category: "xhr", data: l, type: "http" }, p);
2652
+ te().addBreadcrumb({ category: "xhr", data: l, type: "http" }, p);
2653
2653
  }
2654
2654
  function Ja(t) {
2655
2655
  const { startTimestamp: e, endTimestamp: n } = t;
2656
2656
  if (n && (!t.fetchData.url.match(/sentry_key/) || t.fetchData.method !== "POST")) if (t.error) {
2657
2657
  const r = t.fetchData, i = { data: t.error, input: t.args, startTimestamp: e, endTimestamp: n };
2658
- ee().addBreadcrumb({ category: "fetch", data: r, level: "error", type: "http" }, i);
2658
+ te().addBreadcrumb({ category: "fetch", data: r, level: "error", type: "http" }, i);
2659
2659
  } else {
2660
2660
  const r = { ...t.fetchData, status_code: t.response && t.response.status }, i = { input: t.args, response: t.response, startTimestamp: e, endTimestamp: n };
2661
- ee().addBreadcrumb({ category: "fetch", data: r, type: "http" }, i);
2661
+ te().addBreadcrumb({ category: "fetch", data: r, type: "http" }, i);
2662
2662
  }
2663
2663
  }
2664
2664
  function Va(t) {
@@ -2666,7 +2666,7 @@ function Va(t) {
2666
2666
  const r = kn(F.location.href);
2667
2667
  let i = kn(e);
2668
2668
  const s = kn(n);
2669
- i.path || (i = r), r.protocol === s.protocol && r.host === s.host && (n = s.relative), r.protocol === i.protocol && r.host === i.host && (e = i.relative), ee().addBreadcrumb({ category: "navigation", data: { from: e, to: n } });
2669
+ i.path || (i = r), r.protocol === s.protocol && r.host === s.host && (n = s.relative), r.protocol === i.protocol && r.host === i.host && (e = i.relative), te().addBreadcrumb({ category: "navigation", data: { from: e, to: n } });
2670
2670
  }
2671
2671
  Ct.__initStatic();
2672
2672
  class $a extends qe {
@@ -2809,7 +2809,7 @@ function so(t, e, n, r) {
2809
2809
  kt(n, { handled: !1, type: r }), t.captureEvent(n, { originalException: e });
2810
2810
  }
2811
2811
  function oo() {
2812
- const t = ee(), e = t.getClient(), n = e && e.getOptions() || { stackParser: () => [], attachStacktrace: !1 };
2812
+ const t = te(), e = t.getClient(), n = e && e.getOptions() || { stackParser: () => [], attachStacktrace: !1 };
2813
2813
  return [t, n.stackParser, n.attachStacktrace];
2814
2814
  }
2815
2815
  De.__initStatic();
@@ -2907,7 +2907,7 @@ class rt {
2907
2907
  }
2908
2908
  setupOnce() {
2909
2909
  Zs((e) => {
2910
- if (ee().getIntegration(rt)) {
2910
+ if (te().getIntegration(rt)) {
2911
2911
  if (!F.navigator && !F.location && !F.document) return e;
2912
2912
  const n = e.request && e.request.url || F.location && F.location.href, { referrer: r } = F.document || {}, { userAgent: i } = F.navigator || {}, s = { ...e.request && e.request.headers, ...r && { Referer: r }, ...i && { "User-Agent": i } }, a = { ...e.request, ...n && { url: n }, headers: s };
2913
2913
  return { ...e, request: a };
@@ -4027,11 +4027,11 @@ Promise.any || (Promise.any = function() {
4027
4027
  };
4028
4028
  }());
4029
4029
  var Pl = function(t) {
4030
- ln(ne, Ee);
4031
- var e, n, r, i, s, a, c, l, p, h, f, _, k, v, b, T, M, B, L, te, Ne, oe, _e, ht, Rr, xr, Dr, Lr, Nr, jr, Ir, Br, Fr, Ur, qr, Jr, Vr, $r, Ko = Ml(ne);
4032
- function ne(o) {
4030
+ ln(re, Ee);
4031
+ var e, n, r, i, s, a, c, l, p, h, f, _, k, v, b, T, M, B, L, ne, Ne, oe, _e, ht, Rr, xr, Dr, Lr, Nr, jr, Ir, Br, Fr, Ur, qr, Jr, Vr, $r, Ko = Ml(re);
4032
+ function re(o) {
4033
4033
  var u, d, g, m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4034
- if (pe(this, ne), Pe(Se(d = Ko.call(this)), "startListeningForDeviceChanges", function() {
4034
+ if (pe(this, re), Pe(Se(d = Ko.call(this)), "startListeningForDeviceChanges", function() {
4035
4035
  wl(d.handleDeviceChange);
4036
4036
  }), Pe(Se(d), "stopListeningForDeviceChanges", function() {
4037
4037
  Sl(d.handleDeviceChange);
@@ -4056,7 +4056,7 @@ var Pl = function(t) {
4056
4056
  if (d.strictMode) throw new Error("Duplicate DailyIframe instances are not allowed");
4057
4057
  console.warn("Using strictMode: false to allow multiple call instances is now deprecated. Set `allowMultipleCallInstances: true`");
4058
4058
  }
4059
- if (window._daily || (window._daily = { pendings: [], instances: {} }), d.callClientId = dn(), g = Se(d), Be[g.callClientId] = g, window._daily.instances[d.callClientId] = {}, d._sharedTracks = {}, window._daily.instances[d.callClientId].tracks = d._sharedTracks, m.dailyJsVersion = ne.version(), d._iframe = o, d._callObjectMode = m.layout === "none" && !d._iframe, d._preloadCache = { subscribeToTracksAutomatically: !0, audioDeviceId: null, videoDeviceId: null, outputDeviceId: null, inputSettings: null, sendSettings: null, videoTrackForNetworkConnectivityTest: null, videoTrackForConnectionQualityTest: null }, m.showLocalVideo !== void 0 ? d._callObjectMode ? console.error("showLocalVideo is not available in call object mode") : d._showLocalVideo = !!m.showLocalVideo : d._showLocalVideo = !0, m.showParticipantsBar !== void 0 ? d._callObjectMode ? console.error("showParticipantsBar is not available in call object mode") : d._showParticipantsBar = !!m.showParticipantsBar : d._showParticipantsBar = !0, m.customIntegrations !== void 0 ? d._callObjectMode ? console.error("customIntegrations is not available in call object mode") : d._customIntegrations = m.customIntegrations : d._customIntegrations = {}, m.customTrayButtons !== void 0 ? d._callObjectMode ? console.error("customTrayButtons is not available in call object mode") : d._customTrayButtons = m.customTrayButtons : d._customTrayButtons = {}, m.activeSpeakerMode !== void 0 ? d._callObjectMode ? console.error("activeSpeakerMode is not available in call object mode") : d._activeSpeakerMode = !!m.activeSpeakerMode : d._activeSpeakerMode = !1, m.receiveSettings ? d._callObjectMode ? d._receiveSettings = m.receiveSettings : console.error("receiveSettings is only available in call object mode") : d._receiveSettings = {}, d.validateProperties(m), d.properties = P({}, m), d._preloadCache.inputSettings || (d._preloadCache.inputSettings = {}), m.inputSettings && m.inputSettings.audio && (d._preloadCache.inputSettings.audio = m.inputSettings.audio), m.inputSettings && m.inputSettings.video && (d._preloadCache.inputSettings.video = m.inputSettings.video), d._callObjectLoader = d._callObjectMode ? new ll(d.callClientId) : null, d._callState = qi, d._isPreparingToJoin = !1, d._accessState = { access: Cn }, d._meetingSessionSummary = {}, d._finalSummaryOfPrevSession = {}, d._meetingSessionState = Ln(ms, d._callObjectMode), d._nativeInCallAudioMode = fs, d._participants = {}, d._isScreenSharing = !1, d._participantCounts = gs, d._rmpPlayerState = {}, d._waitingParticipants = {}, d._network = { threshold: "good", quality: 100 }, d._activeSpeaker = {}, d._localAudioLevel = 0, d._isLocalAudioLevelObserverRunning = !1, d._remoteParticipantsAudioLevel = {}, d._isRemoteParticipantsAudioLevelObserverRunning = !1, d._messageChannel = N() ? new ol() : new il(), d._iframe && (d._iframe.requestFullscreen ? d._iframe.addEventListener("fullscreenchange", function() {
4059
+ if (window._daily || (window._daily = { pendings: [], instances: {} }), d.callClientId = dn(), g = Se(d), Be[g.callClientId] = g, window._daily.instances[d.callClientId] = {}, d._sharedTracks = {}, window._daily.instances[d.callClientId].tracks = d._sharedTracks, m.dailyJsVersion = re.version(), d._iframe = o, d._callObjectMode = m.layout === "none" && !d._iframe, d._preloadCache = { subscribeToTracksAutomatically: !0, audioDeviceId: null, videoDeviceId: null, outputDeviceId: null, inputSettings: null, sendSettings: null, videoTrackForNetworkConnectivityTest: null, videoTrackForConnectionQualityTest: null }, m.showLocalVideo !== void 0 ? d._callObjectMode ? console.error("showLocalVideo is not available in call object mode") : d._showLocalVideo = !!m.showLocalVideo : d._showLocalVideo = !0, m.showParticipantsBar !== void 0 ? d._callObjectMode ? console.error("showParticipantsBar is not available in call object mode") : d._showParticipantsBar = !!m.showParticipantsBar : d._showParticipantsBar = !0, m.customIntegrations !== void 0 ? d._callObjectMode ? console.error("customIntegrations is not available in call object mode") : d._customIntegrations = m.customIntegrations : d._customIntegrations = {}, m.customTrayButtons !== void 0 ? d._callObjectMode ? console.error("customTrayButtons is not available in call object mode") : d._customTrayButtons = m.customTrayButtons : d._customTrayButtons = {}, m.activeSpeakerMode !== void 0 ? d._callObjectMode ? console.error("activeSpeakerMode is not available in call object mode") : d._activeSpeakerMode = !!m.activeSpeakerMode : d._activeSpeakerMode = !1, m.receiveSettings ? d._callObjectMode ? d._receiveSettings = m.receiveSettings : console.error("receiveSettings is only available in call object mode") : d._receiveSettings = {}, d.validateProperties(m), d.properties = P({}, m), d._preloadCache.inputSettings || (d._preloadCache.inputSettings = {}), m.inputSettings && m.inputSettings.audio && (d._preloadCache.inputSettings.audio = m.inputSettings.audio), m.inputSettings && m.inputSettings.video && (d._preloadCache.inputSettings.video = m.inputSettings.video), d._callObjectLoader = d._callObjectMode ? new ll(d.callClientId) : null, d._callState = qi, d._isPreparingToJoin = !1, d._accessState = { access: Cn }, d._meetingSessionSummary = {}, d._finalSummaryOfPrevSession = {}, d._meetingSessionState = Ln(ms, d._callObjectMode), d._nativeInCallAudioMode = fs, d._participants = {}, d._isScreenSharing = !1, d._participantCounts = gs, d._rmpPlayerState = {}, d._waitingParticipants = {}, d._network = { threshold: "good", quality: 100 }, d._activeSpeaker = {}, d._localAudioLevel = 0, d._isLocalAudioLevelObserverRunning = !1, d._remoteParticipantsAudioLevel = {}, d._isRemoteParticipantsAudioLevelObserverRunning = !1, d._messageChannel = N() ? new ol() : new il(), d._iframe && (d._iframe.requestFullscreen ? d._iframe.addEventListener("fullscreenchange", function() {
4060
4060
  document.fullscreenElement === d._iframe ? (d.emitDailyJSEvent({ action: qt }), d.sendMessageToCallMachine({ action: qt })) : (d.emitDailyJSEvent({ action: Jt }), d.sendMessageToCallMachine({ action: Jt }));
4061
4061
  }) : d._iframe.webkitRequestFullscreen && d._iframe.addEventListener("webkitfullscreenchange", function() {
4062
4062
  document.webkitFullscreenElement === d._iframe ? (d.emitDailyJSEvent({ action: qt }), d.sendMessageToCallMachine({ action: qt })) : (d.emitDailyJSEvent({ action: Jt }), d.sendMessageToCallMachine({ action: Jt }));
@@ -4066,7 +4066,7 @@ var Pl = function(t) {
4066
4066
  }
4067
4067
  return d._callObjectMode && d.startListeningForDeviceChanges(), d._messageChannel.addListenerForMessagesFromCallMachine(d.handleMessageFromCallMachine, d.callClientId, Se(d)), d;
4068
4068
  }
4069
- return fe(ne, [{ key: "destroy", value: ($r = O(function* () {
4069
+ return fe(re, [{ key: "destroy", value: ($r = O(function* () {
4070
4070
  var o, u;
4071
4071
  try {
4072
4072
  yield this.leave();
@@ -4496,7 +4496,7 @@ var Pl = function(t) {
4496
4496
  });
4497
4497
  }), function() {
4498
4498
  return Ne.apply(this, arguments);
4499
- }) }, { key: "startScreenShare", value: (te = O(function* () {
4499
+ }) }, { key: "startScreenShare", value: (ne = O(function* () {
4500
4500
  var o = this, u = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
4501
4501
  if (zt(this._callMachineInitialized, "startScreenShare()"), u.screenVideoSendSettings && this._validateVideoSendSettings("screenVideo", u.screenVideoSendSettings), u.mediaStream && (this._sharedTracks.screenMediaStream = u.mediaStream, u.mediaStream = yt), typeof DailyNativeUtils < "u" && DailyNativeUtils.isIOS !== void 0 && DailyNativeUtils.isIOS) {
4502
4502
  var d = this.nativeUtils();
@@ -4506,7 +4506,7 @@ var Pl = function(t) {
4506
4506
  }), d.presentSystemScreenCapturePrompt();
4507
4507
  } else this.sendMessageToCallMachine({ action: Ki, captureOptions: u });
4508
4508
  }), function() {
4509
- return te.apply(this, arguments);
4509
+ return ne.apply(this, arguments);
4510
4510
  }) }, { key: "stopScreenShare", value: function() {
4511
4511
  zt(this._callMachineInitialized, "stopScreenShare()"), this.sendMessageToCallMachine({ action: "local-screen-stop" });
4512
4512
  } }, { key: "startRecording", value: function() {
@@ -4888,24 +4888,24 @@ var Pl = function(t) {
4888
4888
  } }, { key: "addFakeParticipant", value: function(o) {
4889
4889
  return D(), q(this._callState, "addFakeParticipant()"), this.sendMessageToCallMachine(P({ action: "add-fake-participant" }, o)), this;
4890
4890
  } }, { key: "setShowNamesMode", value: function(o) {
4891
- return Z(this._callObjectMode, "setShowNamesMode()"), D(), o && o !== "always" && o !== "never" ? (console.error('setShowNamesMode argument should be "always", "never", or false'), this) : (this.sendMessageToCallMachine({ action: "set-show-names", mode: o }), this);
4891
+ return ee(this._callObjectMode, "setShowNamesMode()"), D(), o && o !== "always" && o !== "never" ? (console.error('setShowNamesMode argument should be "always", "never", or false'), this) : (this.sendMessageToCallMachine({ action: "set-show-names", mode: o }), this);
4892
4892
  } }, { key: "setShowLocalVideo", value: function() {
4893
4893
  var o = !(arguments.length > 0 && arguments[0] !== void 0) || arguments[0];
4894
- return Z(this._callObjectMode, "setShowLocalVideo()"), D(), q(this._callState, "setShowLocalVideo()"), typeof o != "boolean" ? (console.error("setShowLocalVideo only accepts a boolean value"), this) : (this.sendMessageToCallMachine({ action: "set-show-local-video", show: o }), this._showLocalVideo = o, this);
4894
+ return ee(this._callObjectMode, "setShowLocalVideo()"), D(), q(this._callState, "setShowLocalVideo()"), typeof o != "boolean" ? (console.error("setShowLocalVideo only accepts a boolean value"), this) : (this.sendMessageToCallMachine({ action: "set-show-local-video", show: o }), this._showLocalVideo = o, this);
4895
4895
  } }, { key: "showLocalVideo", value: function() {
4896
- return Z(this._callObjectMode, "showLocalVideo()"), D(), this._showLocalVideo;
4896
+ return ee(this._callObjectMode, "showLocalVideo()"), D(), this._showLocalVideo;
4897
4897
  } }, { key: "setShowParticipantsBar", value: function() {
4898
4898
  var o = !(arguments.length > 0 && arguments[0] !== void 0) || arguments[0];
4899
- return Z(this._callObjectMode, "setShowParticipantsBar()"), D(), q(this._callState, "setShowParticipantsBar()"), typeof o != "boolean" ? (console.error("setShowParticipantsBar only accepts a boolean value"), this) : (this.sendMessageToCallMachine({ action: "set-show-participants-bar", show: o }), this._showParticipantsBar = o, this);
4899
+ return ee(this._callObjectMode, "setShowParticipantsBar()"), D(), q(this._callState, "setShowParticipantsBar()"), typeof o != "boolean" ? (console.error("setShowParticipantsBar only accepts a boolean value"), this) : (this.sendMessageToCallMachine({ action: "set-show-participants-bar", show: o }), this._showParticipantsBar = o, this);
4900
4900
  } }, { key: "showParticipantsBar", value: function() {
4901
- return Z(this._callObjectMode, "showParticipantsBar()"), D(), this._showParticipantsBar;
4901
+ return ee(this._callObjectMode, "showParticipantsBar()"), D(), this._showParticipantsBar;
4902
4902
  } }, { key: "customIntegrations", value: function() {
4903
- return D(), Z(this._callObjectMode, "customIntegrations()"), this._customIntegrations;
4903
+ return D(), ee(this._callObjectMode, "customIntegrations()"), this._customIntegrations;
4904
4904
  } }, { key: "setCustomIntegrations", value: function(o) {
4905
- return D(), Z(this._callObjectMode, "setCustomIntegrations()"), q(this._callState, "setCustomIntegrations()"), Eo(o) ? (this.sendMessageToCallMachine({ action: "set-custom-integrations", integrations: o }), this._customIntegrations = o, this) : this;
4905
+ return D(), ee(this._callObjectMode, "setCustomIntegrations()"), q(this._callState, "setCustomIntegrations()"), Eo(o) ? (this.sendMessageToCallMachine({ action: "set-custom-integrations", integrations: o }), this._customIntegrations = o, this) : this;
4906
4906
  } }, { key: "startCustomIntegrations", value: function(o) {
4907
4907
  var u = this;
4908
- if (D(), Z(this._callObjectMode, "startCustomIntegrations()"), q(this._callState, "startCustomIntegrations()"), Array.isArray(o) && o.some(function(m) {
4908
+ if (D(), ee(this._callObjectMode, "startCustomIntegrations()"), q(this._callState, "startCustomIntegrations()"), Array.isArray(o) && o.some(function(m) {
4909
4909
  return typeof m != "string";
4910
4910
  }) || !Array.isArray(o) && typeof o != "string") return console.error("startCustomIntegrations() only accepts string | string[]"), this;
4911
4911
  var d = typeof o == "string" ? [o] : o, g = d.filter(function(m) {
@@ -4914,7 +4914,7 @@ var Pl = function(t) {
4914
4914
  return g.length ? (console.error(`Can't find custom integration(s): "`.concat(g.join(", "), '"')), this) : (this.sendMessageToCallMachine({ action: "start-custom-integrations", ids: d }), this);
4915
4915
  } }, { key: "stopCustomIntegrations", value: function(o) {
4916
4916
  var u = this;
4917
- if (D(), Z(this._callObjectMode, "stopCustomIntegrations()"), q(this._callState, "stopCustomIntegrations()"), Array.isArray(o) && o.some(function(m) {
4917
+ if (D(), ee(this._callObjectMode, "stopCustomIntegrations()"), q(this._callState, "stopCustomIntegrations()"), Array.isArray(o) && o.some(function(m) {
4918
4918
  return typeof m != "string";
4919
4919
  }) || !Array.isArray(o) && typeof o != "string") return console.error("stopCustomIntegrations() only accepts string | string[]"), this;
4920
4920
  var d = typeof o == "string" ? [o] : o, g = d.filter(function(m) {
@@ -4922,14 +4922,14 @@ var Pl = function(t) {
4922
4922
  });
4923
4923
  return g.length ? (console.error(`Can't find custom integration(s): "`.concat(g.join(", "), '"')), this) : (this.sendMessageToCallMachine({ action: "stop-custom-integrations", ids: d }), this);
4924
4924
  } }, { key: "customTrayButtons", value: function() {
4925
- return Z(this._callObjectMode, "customTrayButtons()"), D(), this._customTrayButtons;
4925
+ return ee(this._callObjectMode, "customTrayButtons()"), D(), this._customTrayButtons;
4926
4926
  } }, { key: "updateCustomTrayButtons", value: function(o) {
4927
- return Z(this._callObjectMode, "updateCustomTrayButtons()"), D(), q(this._callState, "updateCustomTrayButtons()"), ko(o) ? (this.sendMessageToCallMachine({ action: "update-custom-tray-buttons", btns: o }), this._customTrayButtons = o, this) : (console.error("updateCustomTrayButtons only accepts a dictionary of the type ".concat(JSON.stringify(on))), this);
4927
+ return ee(this._callObjectMode, "updateCustomTrayButtons()"), D(), q(this._callState, "updateCustomTrayButtons()"), ko(o) ? (this.sendMessageToCallMachine({ action: "update-custom-tray-buttons", btns: o }), this._customTrayButtons = o, this) : (console.error("updateCustomTrayButtons only accepts a dictionary of the type ".concat(JSON.stringify(on))), this);
4928
4928
  } }, { key: "theme", value: function() {
4929
- return Z(this._callObjectMode, "theme()"), this.properties.theme;
4929
+ return ee(this._callObjectMode, "theme()"), this.properties.theme;
4930
4930
  } }, { key: "setTheme", value: function(o) {
4931
4931
  var u = this;
4932
- return Z(this._callObjectMode, "setTheme()"), new Promise(function(d, g) {
4932
+ return ee(this._callObjectMode, "setTheme()"), new Promise(function(d, g) {
4933
4933
  try {
4934
4934
  u.validateProperties({ theme: o }), u.properties.theme = P({}, o), u.sendMessageToCallMachine({ action: "set-theme", theme: u.properties.theme });
4935
4935
  try {
@@ -5301,7 +5301,7 @@ var Pl = function(t) {
5301
5301
  if (!((u = o.error) !== null && u !== void 0 && u.type && !["connection-error", "end-of-life", "no-room"].includes(o.error.type))) {
5302
5302
  var C = (d = this.properties) !== null && d !== void 0 && d.url ? new URL(this.properties.url) : void 0, x = "production";
5303
5303
  C && C.host.includes(".staging.daily") && (x = "staging");
5304
- var H, G, be, Te, we, _n = new $a({ dsn: "https://f10f1c81e5d44a4098416c0867a8b740@o77906.ingest.sentry.io/168844", transport: Ga, integrations: [new Ui.GlobalHandlers({ onunhandledrejection: !1 }), new Ui.HttpContext()], environment: x }), Y = new br(_n, void 0, ne.version());
5304
+ var H, G, be, Te, we, _n = new $a({ dsn: "https://f10f1c81e5d44a4098416c0867a8b740@o77906.ingest.sentry.io/168844", transport: Ga, integrations: [new Ui.GlobalHandlers({ onunhandledrejection: !1 }), new Ui.HttpContext()], environment: x }), Y = new br(_n, void 0, re.version());
5305
5305
  if (this.session_id && Y.setExtra("sessionId", this.session_id), this.properties) {
5306
5306
  var ge = P({}, this.properties);
5307
5307
  ge.userName = ge.userName ? "[Filtered]" : void 0, ge.userData = ge.userData ? "[Filtered]" : void 0, ge.token = ge.token ? "[Filtered]" : void 0, Y.setExtra("properties", ge);
@@ -5314,7 +5314,7 @@ var Pl = function(t) {
5314
5314
  }
5315
5315
  je && Y.setTag("domain", je);
5316
5316
  }
5317
- o.error && (Y.setTag("fatalErrorType", o.error.type), Y.setExtra("errorDetails", o.error.details), !((H = o.error.details) === null || H === void 0) && H.uri && Y.setTag("serverAddress", o.error.details.uri), !((G = o.error.details) === null || G === void 0) && G.workerGroup && Y.setTag("workerGroup", o.error.details.workerGroup), !((be = o.error.details) === null || be === void 0) && be.geoGroup && Y.setTag("geoGroup", o.error.details.geoGroup), !((Te = o.error.details) === null || Te === void 0) && Te.on && Y.setTag("connectionAttempt", o.error.details.on), (we = o.error.details) !== null && we !== void 0 && we.bundleUrl && (Y.setTag("bundleUrl", o.error.details.bundleUrl), Y.setTag("bundleError", o.error.details.sourceError.type))), Y.setTags({ callMode: this._callObjectMode ? N() ? "reactNative" : (g = this.properties) !== null && g !== void 0 && (m = g.dailyConfig) !== null && m !== void 0 && (w = m.callMode) !== null && w !== void 0 && w.includes("prebuilt") ? this.properties.dailyConfig.callMode : "custom" : "prebuilt-frame", version: ne.version() });
5317
+ o.error && (Y.setTag("fatalErrorType", o.error.type), Y.setExtra("errorDetails", o.error.details), !((H = o.error.details) === null || H === void 0) && H.uri && Y.setTag("serverAddress", o.error.details.uri), !((G = o.error.details) === null || G === void 0) && G.workerGroup && Y.setTag("workerGroup", o.error.details.workerGroup), !((be = o.error.details) === null || be === void 0) && be.geoGroup && Y.setTag("geoGroup", o.error.details.geoGroup), !((Te = o.error.details) === null || Te === void 0) && Te.on && Y.setTag("connectionAttempt", o.error.details.on), (we = o.error.details) !== null && we !== void 0 && we.bundleUrl && (Y.setTag("bundleUrl", o.error.details.bundleUrl), Y.setTag("bundleError", o.error.details.sourceError.type))), Y.setTags({ callMode: this._callObjectMode ? N() ? "reactNative" : (g = this.properties) !== null && g !== void 0 && (m = g.dailyConfig) !== null && m !== void 0 && (w = m.callMode) !== null && w !== void 0 && w.includes("prebuilt") ? this.properties.dailyConfig.callMode : "custom" : "prebuilt-frame", version: re.version() });
5318
5318
  var bn = ((E = o.error) === null || E === void 0 ? void 0 : E.msg) || o.errorMsg;
5319
5319
  Y.run(function(Qo) {
5320
5320
  Qo.captureException(new Error(bn));
@@ -5331,11 +5331,11 @@ var Pl = function(t) {
5331
5331
  return "0.68.0";
5332
5332
  } }, { key: "createCallObject", value: function() {
5333
5333
  var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
5334
- return o.layout = "none", new ne(null, o);
5334
+ return o.layout = "none", new re(null, o);
5335
5335
  } }, { key: "wrap", value: function(o) {
5336
5336
  var u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
5337
5337
  if (D(), !o || !o.contentWindow || typeof o.src != "string") throw new Error("DailyIframe::Wrap needs an iframe-like first argument");
5338
- return u.layout || (u.customLayout ? u.layout = "custom-v1" : u.layout = "browser"), new ne(o, u);
5338
+ return u.layout || (u.customLayout ? u.layout = "custom-v1" : u.layout = "browser"), new re(o, u);
5339
5339
  } }, { key: "createFrame", value: function(o, u) {
5340
5340
  var d, g;
5341
5341
  D(), o && u ? (d = o, g = u) : o && o.append ? (d = o, g = {}) : (d = document.body, g = o || {});
@@ -5346,7 +5346,7 @@ var Pl = function(t) {
5346
5346
  return w.style[E] = m[E];
5347
5347
  }), g.layout || (g.customLayout ? g.layout = "custom-v1" : g.layout = "browser");
5348
5348
  try {
5349
- return new ne(w, g);
5349
+ return new re(w, g);
5350
5350
  } catch (E) {
5351
5351
  throw d.removeChild(w), E;
5352
5352
  }
@@ -5362,11 +5362,11 @@ var Pl = function(t) {
5362
5362
  height: 100%;
5363
5363
  border: 0;
5364
5364
  pointer-events: none;
5365
- `, document.body.appendChild(u), o.layout || (o.layout = "custom-v1"), ne.wrap(u, o);
5365
+ `, document.body.appendChild(u), o.layout || (o.layout = "custom-v1"), re.wrap(u, o);
5366
5366
  } }, { key: "getCallInstance", value: function() {
5367
5367
  var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : void 0;
5368
5368
  return o ? Be[o] : Object.values(Be)[0];
5369
- } }]), ne;
5369
+ } }]), re;
5370
5370
  }();
5371
5371
  function Ke(t, e) {
5372
5372
  var n = {};
@@ -5420,7 +5420,7 @@ function ce(t) {
5420
5420
  throw console.error(e), new Error(e);
5421
5421
  }
5422
5422
  }
5423
- function Z(t) {
5423
+ function ee(t) {
5424
5424
  if (t) {
5425
5425
  var e = "".concat(arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "This daily-js method", " is only supported as part of Daily's Prebuilt");
5426
5426
  throw console.error(e), new Error(e);
@@ -5935,10 +5935,10 @@ function vn(t, e, n) {
5935
5935
  if (y.endsWith(b, "{}"))
5936
5936
  b = r ? b : b.slice(0, -2), v = JSON.stringify(v);
5937
5937
  else if (y.isArray(v) && mu(v) || (y.isFileList(v) || y.endsWith(b, "[]")) && (M = y.toArray(v)))
5938
- return b = jo(b), M.forEach(function(L, te) {
5938
+ return b = jo(b), M.forEach(function(L, ne) {
5939
5939
  !(y.isUndefined(L) || L === null) && e.append(
5940
5940
  // eslint-disable-next-line no-nested-ternary
5941
- a === !0 ? Es([b], te, s) : a === null ? b : b + "[]",
5941
+ a === !0 ? Es([b], ne, s) : a === null ? b : b + "[]",
5942
5942
  p(L)
5943
5943
  );
5944
5944
  }), !1;
@@ -6825,8 +6825,8 @@ const Wu = async (t) => {
6825
6825
  withCredentials: f
6826
6826
  });
6827
6827
  let L = await fetch(T);
6828
- const te = ur && (p === "stream" || p === "response");
6829
- if (ur && (c || te)) {
6828
+ const ne = ur && (p === "stream" || p === "response");
6829
+ if (ur && (c || ne)) {
6830
6830
  const oe = {};
6831
6831
  ["status", "statusText", "headers"].forEach((ht) => {
6832
6832
  oe[ht] = L[ht];
@@ -6836,13 +6836,13 @@ const Wu = async (t) => {
6836
6836
  Ps(L.body, Rs, c && As(
6837
6837
  _e,
6838
6838
  an(c, !0)
6839
- ), te && M, lr),
6839
+ ), ne && M, lr),
6840
6840
  oe
6841
6841
  );
6842
6842
  }
6843
6843
  p = p || "text";
6844
6844
  let Ne = await cn[y.findKey(cn, p) || "text"](L, t);
6845
- return !te && M(), v && v(), await new Promise((oe, _e) => {
6845
+ return !ne && M(), v && v(), await new Promise((oe, _e) => {
6846
6846
  Jo(oe, _e, {
6847
6847
  data: Ne,
6848
6848
  headers: X.from(L.headers),
@@ -7265,23 +7265,31 @@ $.HttpStatusCode = pr;
7265
7265
  $.default = $;
7266
7266
  const Wo = "https://api.avaturn.live";
7267
7267
  class nd {
7268
+ /**
7269
+ * AvaturnHead main class
7270
+ *
7271
+ * @constructor
7272
+ * @param {AvaturnHeadConfig} config - The configuration object for Avaturn Head.
7273
+ */
7268
7274
  constructor({ apiHost: e = Wo, sessionToken: n, preloadBundle: r, preconnect: i, keepAlive: s }) {
7269
- re(this, "inited", !1);
7270
- re(this, "mediaStream");
7271
- re(this, "session_id", "");
7272
- re(this, "timeout", 0);
7273
- re(this, "keepAlive", !1);
7274
- re(this, "fetcher");
7275
- re(this, "call");
7276
- re(this, "handlers", {});
7275
+ Z(this, "inited", !1);
7276
+ Z(this, "mediaStream");
7277
+ Z(this, "session_id", "");
7278
+ Z(this, "abortController");
7279
+ Z(this, "timeout", 0);
7280
+ Z(this, "keepAlive", !1);
7281
+ Z(this, "fetcher");
7282
+ Z(this, "call");
7283
+ Z(this, "handlers", {});
7277
7284
  if (typeof window > "u")
7278
7285
  throw new Error("Unfortunately, SDK only works on the client side.");
7279
- this.fetcher = $.create({
7286
+ this.abortController = new AbortController(), this.fetcher = $.create({
7280
7287
  baseURL: `${e}/_sdk/v0`,
7281
7288
  headers: {
7282
7289
  "X-Session-Token": n
7283
- }
7284
- }), this.keepAlive = !!s, this.keepAlive = !!s, this.mediaStream = new MediaStream(), this.call = Pl.createCallObject({
7290
+ },
7291
+ signal: this.abortController.signal
7292
+ }), this.keepAlive = !!s, this.mediaStream = new MediaStream(), this.call = Pl.createCallObject({
7285
7293
  videoSource: !1,
7286
7294
  audioSource: !1,
7287
7295
  dailyConfig: {
@@ -7303,7 +7311,7 @@ class nd {
7303
7311
  return;
7304
7312
  this.startIdleTimeout();
7305
7313
  const { data: n } = await this.fetcher.get("/sessions");
7306
- return this.session_id = n.id, await this.call.join({
7314
+ return this.session_id = n.id, this.abortController.signal.aborted || await this.call.join({
7307
7315
  token: n.limited_access_token,
7308
7316
  url: n.room_url
7309
7317
  }), new Promise((r, i) => {
@@ -7340,20 +7348,21 @@ class nd {
7340
7348
  }
7341
7349
  async dispose() {
7342
7350
  var e;
7343
- this.inited = !1, this.mediaStream = new MediaStream(), this.timeout && clearTimeout(this.timeout), await ((e = this.call) == null ? void 0 : e.destroy());
7351
+ this.inited = !1, this.mediaStream = new MediaStream(), this.inited = !1, this.timeout && clearTimeout(this.timeout), await ((e = this.call) == null ? void 0 : e.destroy()), this.abortController.abort();
7344
7352
  }
7345
7353
  }
7346
7354
  class id extends nd {
7347
7355
  constructor(n) {
7348
7356
  super(n);
7349
- re(this, "assistantSessionToken", "");
7350
- re(this, "assistantFetcher");
7351
- re(this, "sessionToken", "");
7357
+ Z(this, "assistantSessionToken", "");
7358
+ Z(this, "assistantFetcher");
7359
+ Z(this, "sessionToken", "");
7352
7360
  this.assistantSessionToken = n.assistantSessionToken, this.sessionToken = n.sessionToken, this.assistantFetcher = $.create({
7353
7361
  baseURL: `${n.apiHost || Wo}/`,
7354
7362
  headers: {
7355
7363
  Authorization: `Bearer ${n.assistantSessionToken}`
7356
- }
7364
+ },
7365
+ signal: this.abortController.signal
7357
7366
  });
7358
7367
  }
7359
7368
  async init(n) {
@@ -7392,7 +7401,7 @@ class id extends nd {
7392
7401
  }
7393
7402
  async dispose() {
7394
7403
  var n;
7395
- this.inited = !1, this.mediaStream = new MediaStream(), this.timeout && clearTimeout(this.timeout), await ((n = this.call) == null ? void 0 : n.destroy()), await this.assistantFetcher.delete("/assistants/sessions");
7404
+ this.inited = !1, this.mediaStream = new MediaStream(), this.timeout && clearTimeout(this.timeout), await ((n = this.call) == null ? void 0 : n.destroy()), await this.assistantFetcher.delete("/assistants/sessions"), this.abortController.abort();
7396
7405
  }
7397
7406
  }
7398
7407
  export {
package/dist/type.d.ts CHANGED
@@ -20,8 +20,20 @@ export type AvaturnEventCallback<T extends AvaturnHeadEvent> = (data: AvaturnEve
20
20
  export interface AvaturnHeadConfig {
21
21
  apiHost?: string;
22
22
  sessionToken: string;
23
+ /**
24
+ * Optional flag to preload the asset bundle. Defaults to `false` if not provided.
25
+ * @type {boolean}
26
+ */
23
27
  preloadBundle?: boolean;
28
+ /**
29
+ * Optional flag to preconnect to the API for faster access. Defaults to `false` if not provided.
30
+ * @type {boolean}
31
+ */
24
32
  preconnect?: boolean;
33
+ /**
34
+ * Optional flag to keep the connection alive. Defaults to `false` if not provided.
35
+ * @type {boolean}
36
+ */
25
37
  keepAlive?: boolean;
26
38
  }
27
39
  export interface IAvaturnHead {
@@ -30,6 +42,16 @@ export interface IAvaturnHead {
30
42
  * @type {boolean}
31
43
  */
32
44
  inited: boolean;
45
+ /**
46
+ * MediaStream with audio and video tracks
47
+ * @type {MediaStream}
48
+ */
49
+ mediaStream: MediaStream;
50
+ /**
51
+ * ID of current session.
52
+ * @type {string}
53
+ */
54
+ session_id: string;
33
55
  /**
34
56
  * Initializes the object.
35
57
  * @returns {Promise<unknown>} A promise that resolves after initialization is complete and avatar is ready to use.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@avaturn-live/web-sdk",
3
3
  "private": false,
4
- "version": "0.0.21",
4
+ "version": "0.0.22",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",