hanc-webrtc-widgets 2.1.9 → 2.1.11

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.
@@ -17103,25 +17103,28 @@ class Ed extends EventTarget {
17103
17103
  );
17104
17104
  }
17105
17105
  const { token: r, url: a, room_name: o, user_identity: c } = await s.json();
17106
- if (this.roomName = o, this.userIdentity = c, await n.connect(a, r), t)
17107
- try {
17108
- await n.localParticipant.setMicrophoneEnabled(!0), this.microphoneEnabled = !0, this.dispatchEvent(new CustomEvent("microphone-enabled")), t.getTracks().forEach((l) => l.stop()), setTimeout(() => {
17109
- const l = Array.from(n.localParticipant.audioTrackPublications.values()).find((d) => d.kind === "audio");
17110
- if (l != null && l.track) {
17111
- const d = l.track.mediaStreamTrack;
17112
- d && this.dispatchEvent(
17113
- new CustomEvent("local-audio-track", {
17114
- detail: d
17115
- })
17116
- );
17106
+ this.roomName = o, this.userIdentity = c, await n.connect(a, r), this.updateStatus("connected"), this.isReady = !0, requestAnimationFrame(() => {
17107
+ setTimeout(async () => {
17108
+ if (t)
17109
+ try {
17110
+ await n.localParticipant.setMicrophoneEnabled(!0), this.microphoneEnabled = !0, this.dispatchEvent(new CustomEvent("microphone-enabled")), t.getTracks().forEach((l) => l.stop()), setTimeout(() => {
17111
+ const l = Array.from(n.localParticipant.audioTrackPublications.values()).find((d) => d.kind === "audio");
17112
+ if (l != null && l.track) {
17113
+ const d = l.track.mediaStreamTrack;
17114
+ d && this.dispatchEvent(
17115
+ new CustomEvent("local-audio-track", {
17116
+ detail: d
17117
+ })
17118
+ );
17119
+ }
17120
+ }, 100);
17121
+ } catch (l) {
17122
+ console.warn("Could not enable microphone on connect:", l), this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17117
17123
  }
17118
- }, 100);
17119
- } catch (l) {
17120
- console.warn("Could not enable microphone on connect:", l), this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17121
- }
17122
- else
17123
- this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17124
- this.updateStatus("connected"), this.isReady = !0, this.dispatchEvent(
17124
+ else
17125
+ this.microphoneEnabled = !1, this.dispatchEvent(new CustomEvent("microphone-disabled"));
17126
+ }, 50);
17127
+ }), this.dispatchEvent(
17125
17128
  new CustomEvent("room-connected", {
17126
17129
  detail: { roomName: o, identity: c }
17127
17130
  })
@@ -17252,15 +17255,16 @@ class Ed extends EventTarget {
17252
17255
  return;
17253
17256
  }
17254
17257
  this.updateStatus("disconnecting");
17255
- try {
17256
- await this.room.disconnect(), this.room = null, this.updateStatus("disconnected"), this.connectedParticipants = [], this.microphoneEnabled = !1, this.audioPlaybackPrompt = !1, this.isReady = !1, this.dispatchEvent(new CustomEvent("call-ended"));
17257
- } catch (e) {
17258
- this.error = `Error ending call: ${e instanceof Error ? e.message : String(e)}`, this.updateStatus("error"), this.dispatchEvent(
17259
- new CustomEvent("error", {
17260
- detail: { error: this.error }
17261
- })
17262
- );
17263
- }
17258
+ const e = this.room;
17259
+ this.room = null, this.connectedParticipants = [], this.microphoneEnabled = !1, this.audioPlaybackPrompt = !1, this.isReady = !1, this.updateStatus("disconnected"), this.dispatchEvent(new CustomEvent("call-ended")), requestAnimationFrame(() => {
17260
+ setTimeout(async () => {
17261
+ try {
17262
+ await e.disconnect();
17263
+ } catch (t) {
17264
+ console.warn("Error during room disconnect:", t);
17265
+ }
17266
+ }, 0);
17267
+ });
17264
17268
  }
17265
17269
  }
17266
17270
  /**
@@ -38188,95 +38192,44 @@ class zd {
38188
38192
  return o.gain.setValueAtTime(0, n), o.gain.linearRampToValueAtTime(this.config.volume, n + c), o.gain.linearRampToValueAtTime(this.config.volume * d, n + c + l), o.gain.setValueAtTime(this.config.volume * d, n + s - u), o.gain.linearRampToValueAtTime(0, n + s), a.connect(o), { oscillator: a, gain: o };
38189
38193
  }
38190
38194
  /**
38191
- * Play ascending melodic sound for call start
38192
- * C4 E4 G4 (C major chord arpeggio)
38195
+ * Play pleasant notification sound for call start
38196
+ * Two-tone ascending melody like messenger notifications
38193
38197
  */
38194
38198
  async playCallStartSound() {
38195
38199
  const e = await this.ensureContext();
38196
38200
  if (!e || typeof e.createGain != "function") return;
38197
38201
  const t = e.currentTime, n = e.createGain();
38198
38202
  n.gain.setValueAtTime(1, t), n.connect(e.destination);
38199
- const s = [
38200
- { freq: 261.63, start: 0, duration: 0.5 },
38201
- // C4
38202
- { freq: 329.63, start: 0.15, duration: 0.5 },
38203
- // E4
38204
- { freq: 392, start: 0.3, duration: 0.6 },
38205
- // G4
38206
- { freq: 523.25, start: 0.5, duration: 0.8 }
38207
- // C5 (octave up)
38208
- ], r = [];
38209
- s.forEach((a) => {
38210
- const { oscillator: o, gain: c } = this.createTone(
38211
- e,
38212
- a.freq,
38213
- t + a.start,
38214
- a.duration,
38215
- "sine"
38216
- );
38217
- c.connect(n), o.start(t + a.start), o.stop(t + a.start + a.duration), r.push(o);
38218
- const { oscillator: l, gain: d } = this.createTone(
38219
- e,
38220
- a.freq * 2,
38221
- // Octave up
38222
- t + a.start,
38223
- a.duration,
38224
- "triangle"
38225
- );
38226
- d.gain.setValueAtTime(d.gain.value * 0.3, t), d.connect(n), l.start(t + a.start), l.stop(t + a.start + a.duration), r.push(l);
38227
- }), setTimeout(() => {
38228
- r.forEach((a) => {
38229
- try {
38230
- a.disconnect();
38231
- } catch {
38232
- }
38233
- });
38234
- }, 2e3);
38203
+ const { oscillator: s, gain: r } = this.createTone(e, 880, t, 0.12, "sine");
38204
+ r.connect(n), s.start(t), s.stop(t + 0.12);
38205
+ const { oscillator: a, gain: o } = this.createTone(e, 1046, t + 0.08, 0.15, "sine");
38206
+ o.connect(n), a.start(t + 0.08), a.stop(t + 0.23), setTimeout(() => {
38207
+ try {
38208
+ s.disconnect();
38209
+ } catch {
38210
+ }
38211
+ try {
38212
+ a.disconnect();
38213
+ } catch {
38214
+ }
38215
+ }, 300);
38235
38216
  }
38236
38217
  /**
38237
- * Play descending melodic sound for call end
38238
- * G4 E4 → C4 (descending C major arpeggio)
38218
+ * Play gentle descending sound for call end
38219
+ * Single soft tone
38239
38220
  */
38240
38221
  async playCallEndSound() {
38241
38222
  const e = await this.ensureContext();
38242
38223
  if (!e || typeof e.createGain != "function") return;
38243
38224
  const t = e.currentTime, n = e.createGain();
38244
38225
  n.gain.setValueAtTime(1, t), n.connect(e.destination);
38245
- const s = [
38246
- { freq: 523.25, start: 0, duration: 0.4 },
38247
- // C5
38248
- { freq: 392, start: 0.12, duration: 0.4 },
38249
- // G4
38250
- { freq: 329.63, start: 0.24, duration: 0.5 },
38251
- // E4
38252
- { freq: 261.63, start: 0.4, duration: 0.7 }
38253
- // C4
38254
- ], r = [];
38255
- s.forEach((a) => {
38256
- const { oscillator: o, gain: c } = this.createTone(
38257
- e,
38258
- a.freq,
38259
- t + a.start,
38260
- a.duration,
38261
- "sine"
38262
- );
38263
- c.connect(n), o.start(t + a.start), o.stop(t + a.start + a.duration), r.push(o);
38264
- const { oscillator: l, gain: d } = this.createTone(
38265
- e,
38266
- a.freq * 2,
38267
- t + a.start,
38268
- a.duration,
38269
- "triangle"
38270
- );
38271
- d.gain.setValueAtTime(d.gain.value * 0.25, t), d.connect(n), l.start(t + a.start), l.stop(t + a.start + a.duration), r.push(l);
38272
- }), setTimeout(() => {
38273
- r.forEach((a) => {
38274
- try {
38275
- a.disconnect();
38276
- } catch {
38277
- }
38278
- });
38279
- }, 1500);
38226
+ const { oscillator: s, gain: r } = this.createTone(e, 660, t, 0.2, "sine");
38227
+ r.connect(n), s.start(t), s.stop(t + 0.2), setTimeout(() => {
38228
+ try {
38229
+ s.disconnect();
38230
+ } catch {
38231
+ }
38232
+ }, 250);
38280
38233
  }
38281
38234
  /**
38282
38235
  * Update configuration
@@ -38614,23 +38567,29 @@ let gt = class extends ps {
38614
38567
  }, this.handleMicrophoneDisabled = () => {
38615
38568
  this.microphoneEnabled = !1;
38616
38569
  }, this.handleStatusChange = (i) => {
38617
- var t, n, s, r, a, o, c;
38570
+ var t, n, s, r, a;
38618
38571
  switch (i.detail) {
38619
38572
  case "connecting":
38620
38573
  this.callStatus = "connecting";
38621
38574
  break;
38622
38575
  case "connected":
38623
- this.callStatus = "connected", (t = this.orbRenderer) == null || t.setActive(!0), this.startRealAudioLoop(), (n = this.soundManager) == null || n.playCallStartSound(), this.dispatchEvent(
38576
+ this.callStatus = "connected", (t = this.orbRenderer) == null || t.setActive(!0), this.startRealAudioLoop(), setTimeout(() => {
38577
+ var o;
38578
+ (o = this.soundManager) == null || o.playCallStartSound();
38579
+ }, 300), this.dispatchEvent(
38624
38580
  new Event("call-start", { bubbles: !0, composed: !0 })
38625
38581
  );
38626
38582
  break;
38627
38583
  case "disconnected":
38628
- this.callStatus = "idle", (s = this.orbRenderer) == null || s.setActive(!1), (r = this.audioAnalyzer) == null || r.disconnect(), this.startIdleAnimation(), (a = this.soundManager) == null || a.playCallEndSound(), this.dispatchEvent(
38584
+ this.callStatus = "idle", (n = this.orbRenderer) == null || n.setActive(!1), (s = this.audioAnalyzer) == null || s.disconnect(), this.startIdleAnimation(), setTimeout(() => {
38585
+ var o;
38586
+ (o = this.soundManager) == null || o.playCallEndSound();
38587
+ }, 150), this.dispatchEvent(
38629
38588
  new Event("call-end", { bubbles: !0, composed: !0 })
38630
38589
  );
38631
38590
  break;
38632
38591
  case "error":
38633
- this.callStatus = "error", (o = this.orbRenderer) == null || o.setActive(!1), (c = this.audioAnalyzer) == null || c.disconnect(), setTimeout(() => {
38592
+ this.callStatus = "error", (r = this.orbRenderer) == null || r.setActive(!1), (a = this.audioAnalyzer) == null || a.disconnect(), setTimeout(() => {
38634
38593
  this.callStatus === "error" && (this.callStatus = "idle", this.startIdleAnimation());
38635
38594
  }, 3e3);
38636
38595
  break;
@@ -39120,23 +39079,29 @@ let vt = class extends ps {
39120
39079
  }, this.handleMicrophoneDisabled = () => {
39121
39080
  this.microphoneEnabled = !1;
39122
39081
  }, this.handleStatusChange = (i) => {
39123
- var t, n, s, r, a, o, c;
39082
+ var t, n, s, r, a;
39124
39083
  switch (i.detail) {
39125
39084
  case "connecting":
39126
39085
  this.callStatus = "connecting";
39127
39086
  break;
39128
39087
  case "connected":
39129
- this.callStatus = "connected", (t = this.orbRenderer) == null || t.setActive(!0), this.startRealAudioLoop(), (n = this.soundManager) == null || n.playCallStartSound(), this.dispatchEvent(
39088
+ this.callStatus = "connected", (t = this.orbRenderer) == null || t.setActive(!0), this.startRealAudioLoop(), setTimeout(() => {
39089
+ var o;
39090
+ (o = this.soundManager) == null || o.playCallStartSound();
39091
+ }, 300), this.dispatchEvent(
39130
39092
  new Event("call-start", { bubbles: !0, composed: !0 })
39131
39093
  );
39132
39094
  break;
39133
39095
  case "disconnected":
39134
- this.callStatus = "idle", (s = this.orbRenderer) == null || s.setActive(!1), (r = this.audioAnalyzer) == null || r.disconnect(), this.startIdleAnimation(), (a = this.soundManager) == null || a.playCallEndSound(), this.dispatchEvent(
39096
+ this.callStatus = "idle", (n = this.orbRenderer) == null || n.setActive(!1), (s = this.audioAnalyzer) == null || s.disconnect(), this.startIdleAnimation(), setTimeout(() => {
39097
+ var o;
39098
+ (o = this.soundManager) == null || o.playCallEndSound();
39099
+ }, 150), this.dispatchEvent(
39135
39100
  new Event("call-end", { bubbles: !0, composed: !0 })
39136
39101
  );
39137
39102
  break;
39138
39103
  case "error":
39139
- this.callStatus = "error", (o = this.orbRenderer) == null || o.setActive(!1), (c = this.audioAnalyzer) == null || c.disconnect(), setTimeout(() => {
39104
+ this.callStatus = "error", (r = this.orbRenderer) == null || r.setActive(!1), (a = this.audioAnalyzer) == null || a.disconnect(), setTimeout(() => {
39140
39105
  this.callStatus === "error" && (this.callStatus = "idle", this.startIdleAnimation());
39141
39106
  }, 3e3);
39142
39107
  break;
@@ -39610,23 +39575,29 @@ let _t = class extends ps {
39610
39575
  }, this.handleMicrophoneDisabled = () => {
39611
39576
  this.microphoneEnabled = !1;
39612
39577
  }, this.handleStatusChange = (i) => {
39613
- var t, n, s, r, a, o, c;
39578
+ var t, n, s, r, a;
39614
39579
  switch (i.detail) {
39615
39580
  case "connecting":
39616
39581
  this.callStatus = "connecting";
39617
39582
  break;
39618
39583
  case "connected":
39619
- this.callStatus = "connected", (t = this.orbRenderer) == null || t.setActive(!0), this.startRealAudioLoop(), (n = this.soundManager) == null || n.playCallStartSound(), this.dispatchEvent(
39584
+ this.callStatus = "connected", (t = this.orbRenderer) == null || t.setActive(!0), this.startRealAudioLoop(), setTimeout(() => {
39585
+ var o;
39586
+ (o = this.soundManager) == null || o.playCallStartSound();
39587
+ }, 300), this.dispatchEvent(
39620
39588
  new Event("call-start", { bubbles: !0, composed: !0 })
39621
39589
  );
39622
39590
  break;
39623
39591
  case "disconnected":
39624
- this.callStatus = "idle", (s = this.orbRenderer) == null || s.setActive(!1), (r = this.audioAnalyzer) == null || r.disconnect(), this.startIdleAnimation(), (a = this.soundManager) == null || a.playCallEndSound(), this.dispatchEvent(
39592
+ this.callStatus = "idle", (n = this.orbRenderer) == null || n.setActive(!1), (s = this.audioAnalyzer) == null || s.disconnect(), this.startIdleAnimation(), setTimeout(() => {
39593
+ var o;
39594
+ (o = this.soundManager) == null || o.playCallEndSound();
39595
+ }, 150), this.dispatchEvent(
39625
39596
  new Event("call-end", { bubbles: !0, composed: !0 })
39626
39597
  );
39627
39598
  break;
39628
39599
  case "error":
39629
- this.callStatus = "error", (o = this.orbRenderer) == null || o.setActive(!1), (c = this.audioAnalyzer) == null || c.disconnect(), setTimeout(() => {
39600
+ this.callStatus = "error", (r = this.orbRenderer) == null || r.setActive(!1), (a = this.audioAnalyzer) == null || a.disconnect(), setTimeout(() => {
39630
39601
  this.callStatus === "error" && (this.callStatus = "idle", this.startIdleAnimation());
39631
39602
  }, 3e3);
39632
39603
  break;
@@ -39837,23 +39808,22 @@ let _t = class extends ps {
39837
39808
  }
39838
39809
 
39839
39810
  .microphone-indicator {
39840
- position: absolute;
39841
- top: -4px;
39842
- right: -4px;
39843
- width: 20px;
39844
- height: 20px;
39845
- background: rgba(220, 38, 38, 0.95);
39846
- border-radius: 50%;
39847
39811
  display: flex;
39848
39812
  align-items: center;
39849
39813
  justify-content: center;
39814
+ width: 24px;
39815
+ height: 24px;
39816
+ background: rgba(220, 38, 38, 0.95);
39817
+ border-radius: 50%;
39850
39818
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
39851
- border: 2px solid rgba(255, 255, 255, 0.95);
39852
39819
  pointer-events: none;
39853
39820
  opacity: 0;
39854
- transform: scale(1);
39821
+ transform: scale(0.8);
39855
39822
  transition: opacity 0.3s ease, transform 0.3s ease;
39856
39823
  will-change: opacity, transform;
39824
+ margin-left: -8px;
39825
+ margin-right: 8px;
39826
+ flex-shrink: 0;
39857
39827
  }
39858
39828
 
39859
39829
  .microphone-indicator.visible {
@@ -39862,8 +39832,8 @@ let _t = class extends ps {
39862
39832
  }
39863
39833
 
39864
39834
  .microphone-indicator svg {
39865
- width: 12px;
39866
- height: 12px;
39835
+ width: 14px;
39836
+ height: 14px;
39867
39837
  color: white;
39868
39838
  }
39869
39839
  </style>
@@ -39879,34 +39849,33 @@ let _t = class extends ps {
39879
39849
  class="orb-container"
39880
39850
  part="orb-container"
39881
39851
  ${sd(this.orbContainerRef)}
39882
- >
39883
- ${this.callStatus === "connected" && !this.microphoneEnabled ? Zt`
39884
- <div class="microphone-indicator visible">
39885
- <svg viewBox="0 0 24 24" fill="none">
39886
- <path
39887
- d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"
39888
- fill="currentColor"
39889
- />
39890
- <path
39891
- d="M19 10v2a7 7 0 0 1-14 0v-2"
39892
- stroke="currentColor"
39893
- stroke-width="2"
39894
- stroke-linecap="round"
39895
- stroke-linejoin="round"
39896
- />
39897
- <line
39898
- x1="1"
39899
- y1="1"
39900
- x2="23"
39901
- y2="23"
39902
- stroke="currentColor"
39903
- stroke-width="2"
39904
- stroke-linecap="round"
39905
- />
39906
- </svg>
39907
- </div>
39908
- ` : ""}
39909
- </div>
39852
+ ></div>
39853
+ ${this.callStatus === "connected" && !this.microphoneEnabled ? Zt`
39854
+ <div class="microphone-indicator visible">
39855
+ <svg viewBox="0 0 24 24" fill="none">
39856
+ <path
39857
+ d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"
39858
+ fill="currentColor"
39859
+ />
39860
+ <path
39861
+ d="M19 10v2a7 7 0 0 1-14 0v-2"
39862
+ stroke="currentColor"
39863
+ stroke-width="2"
39864
+ stroke-linecap="round"
39865
+ stroke-linejoin="round"
39866
+ />
39867
+ <line
39868
+ x1="1"
39869
+ y1="1"
39870
+ x2="23"
39871
+ y2="23"
39872
+ stroke="currentColor"
39873
+ stroke-width="2"
39874
+ stroke-linecap="round"
39875
+ />
39876
+ </svg>
39877
+ </div>
39878
+ ` : ""}
39910
39879
  <span class="pill-text">${this.buttonText}</span>
39911
39880
  ${this.callStatus !== "idle" ? Zt`<span class="icon-wrapper">${this.getButtonIcon()}</span>` : ""}
39912
39881
  </button>