@whereby.com/assistant-sdk 0.0.0-canary-20251002113535 → 0.0.0-canary-20251007140529
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/README.md +119 -1
- package/dist/index.cjs +123 -203
- package/dist/index.d.cts +61 -53
- package/dist/index.d.mts +61 -53
- package/dist/index.d.ts +61 -53
- package/dist/index.mjs +124 -184
- package/dist/legacy-esm.js +124 -184
- package/dist/tools.cjs +9 -17
- package/dist/tools.d.ts +1 -2
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2,16 +2,12 @@ import { WherebyClient } from '@whereby.com/core';
|
|
|
2
2
|
import wrtc from '@roamhq/wrtc';
|
|
3
3
|
import EventEmitter$1, { EventEmitter } from 'events';
|
|
4
4
|
import { spawn } from 'child_process';
|
|
5
|
-
import { PassThrough } from 'stream';
|
|
6
5
|
import express from 'express';
|
|
7
6
|
import assert from 'assert';
|
|
8
7
|
import bodyParser from 'body-parser';
|
|
9
|
-
import { networkInterfaces } from 'os';
|
|
10
|
-
import * as dotenv from 'dotenv';
|
|
11
8
|
|
|
12
9
|
const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
13
10
|
|
|
14
|
-
const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
15
11
|
const ASSISTANT_JOINED_ROOM = "ASSISTANT_JOINED_ROOM";
|
|
16
12
|
const ASSISTANT_LEFT_ROOM = "ASSISTANT_LEFT_ROOM";
|
|
17
13
|
const PARTICIPANT_VIDEO_TRACK_ADDED = "PARTICIPANT_VIDEO_TRACK_ADDED";
|
|
@@ -19,48 +15,10 @@ const PARTICIPANT_VIDEO_TRACK_REMOVED = "PARTICIPANT_VIDEO_TRACK_REMOVED";
|
|
|
19
15
|
const PARTICIPANT_AUDIO_TRACK_ADDED = "PARTICIPANT_AUDIO_TRACK_ADDED";
|
|
20
16
|
const PARTICIPANT_AUDIO_TRACK_REMOVED = "PARTICIPANT_AUDIO_TRACK_REMOVED";
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
26
|
-
purpose with or without fee is hereby granted.
|
|
27
|
-
|
|
28
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
29
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
30
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
31
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
32
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
33
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
34
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
-
***************************************************************************** */
|
|
36
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
40
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
41
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
42
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
43
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
44
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
45
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const { nonstandard: { RTCAudioSink }, } = wrtc;
|
|
55
|
-
class AudioSource extends PassThrough {
|
|
56
|
-
constructor() {
|
|
57
|
-
super({
|
|
58
|
-
allowHalfOpen: true,
|
|
59
|
-
highWaterMark: 1 * 1024,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
18
|
+
const { nonstandard: { RTCAudioSink, RTCAudioSource }, } = wrtc;
|
|
19
|
+
class AudioSource extends RTCAudioSource {
|
|
62
20
|
}
|
|
63
|
-
class AudioSink extends
|
|
21
|
+
class AudioSink extends RTCAudioSink {
|
|
64
22
|
constructor(track) {
|
|
65
23
|
super(track);
|
|
66
24
|
this._sink = new RTCAudioSink(track);
|
|
@@ -168,7 +126,7 @@ function createFfmpegMixer() {
|
|
|
168
126
|
* @param ff Child process handle from spawn("ffmpeg", ...)
|
|
169
127
|
* @param slotCount Number of participant input slots (0..N-1 → fd 3..3+N-1)
|
|
170
128
|
*/
|
|
171
|
-
function startPacer(ff, slotCount, rtcAudioSource
|
|
129
|
+
function startPacer(ff, slotCount, rtcAudioSource) {
|
|
172
130
|
if (stopPacerFn) {
|
|
173
131
|
stopPacerFn();
|
|
174
132
|
stopPacerFn = null;
|
|
@@ -186,8 +144,6 @@ function createFfmpegMixer() {
|
|
|
186
144
|
frameQueue: [],
|
|
187
145
|
nextDueMs: t0 + outputFrameMs,
|
|
188
146
|
rtcAudioSource,
|
|
189
|
-
onAudioStreamReady,
|
|
190
|
-
didEmitReadyEvent: false,
|
|
191
147
|
};
|
|
192
148
|
const iv = setInterval(() => {
|
|
193
149
|
const t = nowMs();
|
|
@@ -215,10 +171,6 @@ function createFfmpegMixer() {
|
|
|
215
171
|
const state = outputPacerState;
|
|
216
172
|
if (t >= state.nextDueMs) {
|
|
217
173
|
const samples = state.frameQueue.length > 0 ? state.frameQueue.shift() : new Int16Array(FRAME_10MS_SAMPLES); // silence
|
|
218
|
-
if (!state.didEmitReadyEvent) {
|
|
219
|
-
state.onAudioStreamReady();
|
|
220
|
-
state.didEmitReadyEvent = true;
|
|
221
|
-
}
|
|
222
174
|
state.rtcAudioSource.onData({
|
|
223
175
|
samples: samples,
|
|
224
176
|
sampleRate: STREAM_INPUT_SAMPLE_RATE_IN_HZ,
|
|
@@ -321,11 +273,11 @@ function createFfmpegMixer() {
|
|
|
321
273
|
* The process will log its output to stderr.
|
|
322
274
|
* @return The spawned FFmpeg process.
|
|
323
275
|
*/
|
|
324
|
-
function spawnFFmpegProcessDebug(rtcAudioSource
|
|
276
|
+
function spawnFFmpegProcessDebug(rtcAudioSource) {
|
|
325
277
|
const stdio = ["ignore", "ignore", "pipe", ...Array(PARTICIPANT_SLOTS).fill("pipe")];
|
|
326
278
|
const args = getFFmpegArgumentsDebug();
|
|
327
279
|
const ffmpegProcess = spawn("ffmpeg", args, { stdio });
|
|
328
|
-
startPacer(ffmpegProcess, PARTICIPANT_SLOTS, rtcAudioSource
|
|
280
|
+
startPacer(ffmpegProcess, PARTICIPANT_SLOTS, rtcAudioSource);
|
|
329
281
|
ffmpegProcess.stderr.setEncoding("utf8");
|
|
330
282
|
ffmpegProcess.stderr.on("data", (d) => console.error("[ffmpeg]", String(d).trim()));
|
|
331
283
|
ffmpegProcess.on("error", () => console.error("FFmpeg process error (debug): is ffmpeg installed?"));
|
|
@@ -339,11 +291,11 @@ function createFfmpegMixer() {
|
|
|
339
291
|
* @param rtcAudioSource The RTCAudioSource to which the mixed audio will be sent.
|
|
340
292
|
* @return The spawned FFmpeg process.
|
|
341
293
|
*/
|
|
342
|
-
function spawnFFmpegProcess(rtcAudioSource
|
|
294
|
+
function spawnFFmpegProcess(rtcAudioSource) {
|
|
343
295
|
const stdio = ["pipe", "pipe", "pipe", ...Array(PARTICIPANT_SLOTS).fill("pipe")];
|
|
344
296
|
const args = getFFmpegArguments();
|
|
345
297
|
const ffmpegProcess = spawn("ffmpeg", args, { stdio });
|
|
346
|
-
startPacer(ffmpegProcess, PARTICIPANT_SLOTS, rtcAudioSource
|
|
298
|
+
startPacer(ffmpegProcess, PARTICIPANT_SLOTS, rtcAudioSource);
|
|
347
299
|
ffmpegProcess.stderr.setEncoding("utf8");
|
|
348
300
|
ffmpegProcess.stderr.on("data", (d) => console.error("[ffmpeg]", String(d).trim()));
|
|
349
301
|
ffmpegProcess.on("error", () => console.error("FFmpeg process error: is ffmpeg installed?"));
|
|
@@ -441,7 +393,7 @@ function createFfmpegMixer() {
|
|
|
441
393
|
}
|
|
442
394
|
|
|
443
395
|
class AudioMixer extends EventEmitter {
|
|
444
|
-
constructor(
|
|
396
|
+
constructor() {
|
|
445
397
|
super();
|
|
446
398
|
this.ffmpegProcess = null;
|
|
447
399
|
this.combinedAudioStream = null;
|
|
@@ -451,7 +403,6 @@ class AudioMixer extends EventEmitter {
|
|
|
451
403
|
this.mixer = createFfmpegMixer();
|
|
452
404
|
this.setupMediaStream();
|
|
453
405
|
this.participantSlots = new Map(Array.from({ length: PARTICIPANT_SLOTS }, (_, i) => [i, ""]));
|
|
454
|
-
this.onStreamReady = onStreamReady;
|
|
455
406
|
}
|
|
456
407
|
setupMediaStream() {
|
|
457
408
|
this.rtcAudioSource = new wrtc.nonstandard.RTCAudioSource();
|
|
@@ -467,7 +418,7 @@ class AudioMixer extends EventEmitter {
|
|
|
467
418
|
return;
|
|
468
419
|
}
|
|
469
420
|
if (!this.ffmpegProcess && this.rtcAudioSource) {
|
|
470
|
-
this.ffmpegProcess = this.mixer.spawnFFmpegProcess(this.rtcAudioSource
|
|
421
|
+
this.ffmpegProcess = this.mixer.spawnFFmpegProcess(this.rtcAudioSource);
|
|
471
422
|
}
|
|
472
423
|
for (const p of participants)
|
|
473
424
|
this.attachParticipantIfNeeded(p);
|
|
@@ -557,12 +508,28 @@ class AudioMixer extends EventEmitter {
|
|
|
557
508
|
}
|
|
558
509
|
}
|
|
559
510
|
|
|
511
|
+
const { nonstandard: { RTCVideoSink, RTCVideoSource }, } = wrtc;
|
|
512
|
+
class VideoSource extends RTCVideoSource {
|
|
513
|
+
}
|
|
514
|
+
class VideoSink extends RTCVideoSink {
|
|
515
|
+
constructor(track) {
|
|
516
|
+
super(track);
|
|
517
|
+
this._sink = new RTCVideoSink(track);
|
|
518
|
+
}
|
|
519
|
+
subscribe(cb) {
|
|
520
|
+
this._sink.onframe = cb;
|
|
521
|
+
return () => {
|
|
522
|
+
this._sink.onframe = undefined;
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
560
527
|
class Assistant extends EventEmitter$1 {
|
|
561
|
-
constructor({ assistantKey
|
|
528
|
+
constructor({ assistantKey }) {
|
|
562
529
|
super();
|
|
563
|
-
this.
|
|
564
|
-
this.
|
|
565
|
-
this.
|
|
530
|
+
this.localAudioSource = null;
|
|
531
|
+
this.localVideoSource = null;
|
|
532
|
+
this.combinedAudioSink = null;
|
|
566
533
|
this.remoteMediaTracks = {};
|
|
567
534
|
this.roomUrl = null;
|
|
568
535
|
this.stateSubscriptions = [];
|
|
@@ -583,28 +550,34 @@ class Assistant extends EventEmitter$1 {
|
|
|
583
550
|
const tracks = stream.getTracks();
|
|
584
551
|
tracks.forEach((track) => {
|
|
585
552
|
if (!this.remoteMediaTracks[track.id]) {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
553
|
+
if (track.kind === "video") {
|
|
554
|
+
this.emit(PARTICIPANT_VIDEO_TRACK_ADDED, {
|
|
555
|
+
participantId,
|
|
556
|
+
trackId: track.id,
|
|
557
|
+
data: new VideoSink(track),
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
this.emit(PARTICIPANT_AUDIO_TRACK_ADDED, {
|
|
562
|
+
participantId,
|
|
563
|
+
trackId: track.id,
|
|
564
|
+
data: new AudioSink(track),
|
|
565
|
+
});
|
|
566
|
+
}
|
|
592
567
|
this.remoteMediaTracks[track.id] = {
|
|
593
568
|
participantId,
|
|
594
|
-
stream,
|
|
595
569
|
track,
|
|
596
570
|
};
|
|
597
571
|
}
|
|
598
572
|
});
|
|
599
573
|
return tracks;
|
|
600
574
|
});
|
|
601
|
-
Object.values(this.remoteMediaTracks).forEach(({ participantId,
|
|
575
|
+
Object.values(this.remoteMediaTracks).forEach(({ participantId, track }) => {
|
|
602
576
|
if (!currentRemoteMediaTracks.includes(track)) {
|
|
603
577
|
const eventName = track.kind === "video" ? PARTICIPANT_VIDEO_TRACK_REMOVED : PARTICIPANT_AUDIO_TRACK_REMOVED;
|
|
604
578
|
this.emit(eventName, {
|
|
605
579
|
participantId,
|
|
606
|
-
|
|
607
|
-
track,
|
|
580
|
+
trackId: track.id,
|
|
608
581
|
});
|
|
609
582
|
delete this.remoteMediaTracks[track.id];
|
|
610
583
|
}
|
|
@@ -614,135 +587,102 @@ class Assistant extends EventEmitter$1 {
|
|
|
614
587
|
this.client = new WherebyClient();
|
|
615
588
|
this.roomConnection = this.client.getRoomConnection();
|
|
616
589
|
this.localMedia = this.client.getLocalMedia();
|
|
617
|
-
if (startLocalMedia) {
|
|
618
|
-
const outputAudioSource = new wrtc.nonstandard.RTCAudioSource();
|
|
619
|
-
const outputMediaStream = new wrtc.MediaStream([outputAudioSource.createTrack()]);
|
|
620
|
-
this.mediaStream = outputMediaStream;
|
|
621
|
-
this.audioSource = outputAudioSource;
|
|
622
|
-
}
|
|
623
|
-
if (startCombinedAudioStream) {
|
|
624
|
-
const handleStreamReady = () => {
|
|
625
|
-
if (!this.combinedStream) {
|
|
626
|
-
console.warn("Combined stream is not available");
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
this.emit(AUDIO_STREAM_READY, {
|
|
630
|
-
stream: this.combinedStream,
|
|
631
|
-
track: this.combinedStream.getAudioTracks()[0],
|
|
632
|
-
});
|
|
633
|
-
};
|
|
634
|
-
const audioMixer = new AudioMixer(handleStreamReady);
|
|
635
|
-
this.combinedStream = audioMixer.getCombinedAudioStream();
|
|
636
|
-
this.stateSubscriptions.push(this.roomConnection.subscribeToRemoteParticipants(audioMixer.handleRemoteParticipants.bind(audioMixer)));
|
|
637
|
-
}
|
|
638
590
|
this.stateSubscriptions.push(this.roomConnection.subscribeToConnectionStatus(this.handleConnectionStatusChange));
|
|
639
591
|
this.stateSubscriptions.push(this.roomConnection.subscribeToRemoteParticipants(this.handleRemoteParticipantsTracksChange));
|
|
640
592
|
}
|
|
641
593
|
joinRoom(roomUrl) {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
},
|
|
652
|
-
roomUrl,
|
|
653
|
-
isNodeSdk: true,
|
|
654
|
-
assistantKey: this.assistantKey,
|
|
655
|
-
});
|
|
656
|
-
return this.roomConnection.joinRoom();
|
|
594
|
+
this.roomUrl = roomUrl;
|
|
595
|
+
this.roomConnection.initialize({
|
|
596
|
+
localMediaOptions: {
|
|
597
|
+
audio: false,
|
|
598
|
+
video: false,
|
|
599
|
+
},
|
|
600
|
+
roomUrl,
|
|
601
|
+
isNodeSdk: true,
|
|
602
|
+
assistantKey: this.assistantKey,
|
|
657
603
|
});
|
|
658
|
-
|
|
659
|
-
startLocalMedia() {
|
|
660
|
-
if (!this.mediaStream) {
|
|
661
|
-
const outputAudioSource = new wrtc.nonstandard.RTCAudioSource();
|
|
662
|
-
const outputMediaStream = new wrtc.MediaStream([outputAudioSource.createTrack()]);
|
|
663
|
-
this.mediaStream = outputMediaStream;
|
|
664
|
-
this.audioSource = outputAudioSource;
|
|
665
|
-
}
|
|
666
|
-
this.localMedia.startMedia(this.mediaStream);
|
|
667
|
-
}
|
|
668
|
-
getLocalMediaStream() {
|
|
669
|
-
return this.mediaStream;
|
|
670
|
-
}
|
|
671
|
-
getLocalAudioSource() {
|
|
672
|
-
return this.audioSource;
|
|
604
|
+
return this.roomConnection.joinRoom();
|
|
673
605
|
}
|
|
674
606
|
getRoomConnection() {
|
|
675
607
|
return this.roomConnection;
|
|
676
608
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
this.
|
|
609
|
+
startLocalMedia() {
|
|
610
|
+
if (Boolean(this.localAudioSource) || Boolean(this.localVideoSource)) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
this.localAudioSource = new AudioSource();
|
|
614
|
+
this.localVideoSource = new VideoSource();
|
|
615
|
+
const outputMediaStream = new wrtc.MediaStream([
|
|
616
|
+
this.localAudioSource.createTrack(),
|
|
617
|
+
this.localVideoSource.createTrack(),
|
|
618
|
+
]);
|
|
619
|
+
this.localMedia.startMedia(outputMediaStream);
|
|
620
|
+
this.localMedia.toggleMicrophone(true);
|
|
621
|
+
}
|
|
622
|
+
stopLocalMedia() {
|
|
623
|
+
this.localMedia.stopMedia();
|
|
624
|
+
this.localAudioSource = null;
|
|
625
|
+
this.localVideoSource = null;
|
|
688
626
|
}
|
|
689
|
-
|
|
690
|
-
this.
|
|
627
|
+
getLocalAudioSource() {
|
|
628
|
+
return this.localAudioSource;
|
|
691
629
|
}
|
|
692
|
-
|
|
693
|
-
this.
|
|
630
|
+
getLocalVideoSource() {
|
|
631
|
+
return this.localVideoSource;
|
|
694
632
|
}
|
|
695
|
-
|
|
696
|
-
this.
|
|
633
|
+
getLocalMedia() {
|
|
634
|
+
return this.localMedia;
|
|
697
635
|
}
|
|
698
|
-
|
|
699
|
-
if (
|
|
700
|
-
this.
|
|
701
|
-
}
|
|
702
|
-
else {
|
|
703
|
-
this.roomConnection.muteParticipants([participantId]);
|
|
636
|
+
getCombinedAudioSink() {
|
|
637
|
+
if (this.combinedAudioSink) {
|
|
638
|
+
return this.combinedAudioSink;
|
|
704
639
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
this.
|
|
640
|
+
const audioMixer = new AudioMixer();
|
|
641
|
+
const stream = audioMixer.getCombinedAudioStream();
|
|
642
|
+
const audioTracks = stream === null || stream === void 0 ? void 0 : stream.getAudioTracks();
|
|
643
|
+
if (audioTracks === null || audioTracks === void 0 ? void 0 : audioTracks.length) {
|
|
644
|
+
this.combinedAudioSink = new AudioSink(audioTracks[0]);
|
|
645
|
+
this.stateSubscriptions.push(this.roomConnection.subscribeToRemoteParticipants(audioMixer.handleRemoteParticipants.bind(audioMixer)));
|
|
646
|
+
return this.combinedAudioSink;
|
|
712
647
|
}
|
|
713
|
-
|
|
714
|
-
acceptWaitingParticipant(participantId) {
|
|
715
|
-
this.roomConnection.acceptWaitingParticipant(participantId);
|
|
716
|
-
}
|
|
717
|
-
rejectWaitingParticipant(participantId) {
|
|
718
|
-
this.roomConnection.rejectWaitingParticipant(participantId);
|
|
719
|
-
}
|
|
720
|
-
subscribeToRemoteParticipants(callback) {
|
|
721
|
-
return this.roomConnection.subscribeToRemoteParticipants(callback);
|
|
722
|
-
}
|
|
723
|
-
subscribeToChatMessages(callback) {
|
|
724
|
-
return this.roomConnection.subscribeToChatMessages(callback);
|
|
648
|
+
return null;
|
|
725
649
|
}
|
|
726
650
|
}
|
|
727
651
|
|
|
728
|
-
|
|
729
|
-
|
|
652
|
+
/******************************************************************************
|
|
653
|
+
Copyright (c) Microsoft Corporation.
|
|
654
|
+
|
|
655
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
656
|
+
purpose with or without fee is hereby granted.
|
|
657
|
+
|
|
658
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
659
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
660
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
661
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
662
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
663
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
664
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
665
|
+
***************************************************************************** */
|
|
666
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
670
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
671
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
672
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
673
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
674
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
675
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
680
|
+
var e = new Error(message);
|
|
681
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
682
|
+
};
|
|
683
|
+
|
|
730
684
|
function buildRoomUrl(roomPath, wherebySubdomain, baseDomain = "whereby.com") {
|
|
731
|
-
|
|
732
|
-
if (IS_LOCAL === "true") {
|
|
733
|
-
const ifaceAddrs = networkInterfaces()[BIND_INTERFACE];
|
|
734
|
-
if (!ifaceAddrs) {
|
|
735
|
-
throw new Error(`Unknown interface ${BIND_INTERFACE}`);
|
|
736
|
-
}
|
|
737
|
-
const [bindAddr] = ifaceAddrs.filter((iface) => iface.family === "IPv4");
|
|
738
|
-
if (!bindAddr) {
|
|
739
|
-
throw new Error(`No IPv4 address found for interface ${BIND_INTERFACE}`);
|
|
740
|
-
}
|
|
741
|
-
wherebyDomain = `${wherebySubdomain}-ip-${bindAddr.address.replace(/[.]/g, "-")}.hereby.dev:4443`;
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
wherebyDomain = `${wherebySubdomain}.${baseDomain}`;
|
|
745
|
-
}
|
|
685
|
+
const wherebyDomain = `${wherebySubdomain}.${baseDomain}`;
|
|
746
686
|
return `https://${wherebyDomain}${roomPath}`;
|
|
747
687
|
}
|
|
748
688
|
|
|
@@ -801,4 +741,4 @@ class Trigger extends EventEmitter {
|
|
|
801
741
|
}
|
|
802
742
|
}
|
|
803
743
|
|
|
804
|
-
export { ASSISTANT_JOINED_ROOM, ASSISTANT_LEFT_ROOM,
|
|
744
|
+
export { ASSISTANT_JOINED_ROOM, ASSISTANT_LEFT_ROOM, Assistant, AudioSink, AudioSource, PARTICIPANT_AUDIO_TRACK_ADDED, PARTICIPANT_AUDIO_TRACK_REMOVED, PARTICIPANT_VIDEO_TRACK_ADDED, PARTICIPANT_VIDEO_TRACK_REMOVED, TRIGGER_EVENT_SUCCESS, Trigger };
|