@cuekit-ai/react 1.3.1 → 1.3.2
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/{chunk-PLOG3DEN.mjs → chunk-H44FBEX3.mjs} +459 -829
- package/dist/chunk-R7POPVJR.mjs +35 -0
- package/dist/chunk-Y2Q57RZJ.mjs +764 -0
- package/dist/index.js +751 -308
- package/dist/index.mjs +50 -34
- package/dist/livekit-client.esm-33GHDCYA.mjs +219 -0
- package/dist/{webrtc-service-BHI4M7YJ.mjs → webrtc-service-TL73OATV.mjs} +2 -1
- package/package.json +1 -1
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
12
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
-
mod
|
|
29
|
-
));
|
|
30
|
-
|
|
31
1
|
// node_modules/livekit-client/dist/livekit-client.esm.mjs
|
|
32
2
|
function _mergeNamespaces(n, m) {
|
|
33
3
|
m.forEach(function(e2) {
|
|
@@ -5715,6 +5685,34 @@ function getLogger(name) {
|
|
|
5715
5685
|
logger.setDefaultLevel(livekitLogger.getLevel());
|
|
5716
5686
|
return logger;
|
|
5717
5687
|
}
|
|
5688
|
+
function setLogLevel(level, loggerName) {
|
|
5689
|
+
if (loggerName) {
|
|
5690
|
+
loglevelExports.getLogger(loggerName).setLevel(level);
|
|
5691
|
+
} else {
|
|
5692
|
+
for (const logger of livekitLoggers) {
|
|
5693
|
+
logger.setLevel(level);
|
|
5694
|
+
}
|
|
5695
|
+
}
|
|
5696
|
+
}
|
|
5697
|
+
function setLogExtension(extension, logger) {
|
|
5698
|
+
const loggers = logger ? [logger] : livekitLoggers;
|
|
5699
|
+
loggers.forEach((logR) => {
|
|
5700
|
+
const originalFactory = logR.methodFactory;
|
|
5701
|
+
logR.methodFactory = (methodName, configLevel, loggerName) => {
|
|
5702
|
+
const rawMethod = originalFactory(methodName, configLevel, loggerName);
|
|
5703
|
+
const logLevel = LogLevel[methodName];
|
|
5704
|
+
const needLog = logLevel >= configLevel && logLevel < LogLevel.silent;
|
|
5705
|
+
return (msg, context) => {
|
|
5706
|
+
if (context) rawMethod(msg, context);
|
|
5707
|
+
else rawMethod(msg);
|
|
5708
|
+
if (needLog) {
|
|
5709
|
+
extension(logLevel, msg, context);
|
|
5710
|
+
}
|
|
5711
|
+
};
|
|
5712
|
+
};
|
|
5713
|
+
logR.setLevel(logR.getLevel());
|
|
5714
|
+
});
|
|
5715
|
+
}
|
|
5718
5716
|
var workerLogger = loglevelExports.getLogger("lk-e2ee");
|
|
5719
5717
|
var maxRetryDelay = 7e3;
|
|
5720
5718
|
var DEFAULT_RETRY_DELAYS_IN_MS = [0, 300, 2 * 2 * 300, 3 * 3 * 300, 4 * 4 * 300, maxRetryDelay, maxRetryDelay, maxRetryDelay, maxRetryDelay, maxRetryDelay];
|
|
@@ -8678,6 +8676,7 @@ function adapterFactory() {
|
|
|
8678
8676
|
adapterFactory({
|
|
8679
8677
|
window: typeof window === "undefined" ? void 0 : window
|
|
8680
8678
|
});
|
|
8679
|
+
var ENCRYPTION_ALGORITHM = "AES-GCM";
|
|
8681
8680
|
var DECRYPTION_FAILURE_TOLERANCE = 10;
|
|
8682
8681
|
var E2EE_FLAG = "lk_e2ee";
|
|
8683
8682
|
var SALT = "LKFrameEncryptionKey";
|
|
@@ -8717,6 +8716,120 @@ function isInsertableStreamSupported() {
|
|
|
8717
8716
|
return typeof window.RTCRtpSender !== "undefined" && // @ts-ignore
|
|
8718
8717
|
typeof window.RTCRtpSender.prototype.createEncodedStreams !== "undefined";
|
|
8719
8718
|
}
|
|
8719
|
+
function isVideoFrame(frame) {
|
|
8720
|
+
return "type" in frame;
|
|
8721
|
+
}
|
|
8722
|
+
function importKey(keyBytes_1) {
|
|
8723
|
+
return __awaiter(this, arguments, void 0, function(keyBytes) {
|
|
8724
|
+
let algorithm = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
8725
|
+
name: ENCRYPTION_ALGORITHM
|
|
8726
|
+
};
|
|
8727
|
+
let usage = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "encrypt";
|
|
8728
|
+
return function* () {
|
|
8729
|
+
return crypto.subtle.importKey("raw", keyBytes, algorithm, false, usage === "derive" ? ["deriveBits", "deriveKey"] : ["encrypt", "decrypt"]);
|
|
8730
|
+
}();
|
|
8731
|
+
});
|
|
8732
|
+
}
|
|
8733
|
+
function createKeyMaterialFromString(password) {
|
|
8734
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8735
|
+
let enc = new TextEncoder();
|
|
8736
|
+
const keyMaterial = yield crypto.subtle.importKey("raw", enc.encode(password), {
|
|
8737
|
+
name: "PBKDF2"
|
|
8738
|
+
}, false, ["deriveBits", "deriveKey"]);
|
|
8739
|
+
return keyMaterial;
|
|
8740
|
+
});
|
|
8741
|
+
}
|
|
8742
|
+
function createKeyMaterialFromBuffer(cryptoBuffer) {
|
|
8743
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8744
|
+
const keyMaterial = yield crypto.subtle.importKey("raw", cryptoBuffer, "HKDF", false, ["deriveBits", "deriveKey"]);
|
|
8745
|
+
return keyMaterial;
|
|
8746
|
+
});
|
|
8747
|
+
}
|
|
8748
|
+
function getAlgoOptions(algorithmName, salt) {
|
|
8749
|
+
const textEncoder = new TextEncoder();
|
|
8750
|
+
const encodedSalt = textEncoder.encode(salt);
|
|
8751
|
+
switch (algorithmName) {
|
|
8752
|
+
case "HKDF":
|
|
8753
|
+
return {
|
|
8754
|
+
name: "HKDF",
|
|
8755
|
+
salt: encodedSalt,
|
|
8756
|
+
hash: "SHA-256",
|
|
8757
|
+
info: new ArrayBuffer(128)
|
|
8758
|
+
};
|
|
8759
|
+
case "PBKDF2": {
|
|
8760
|
+
return {
|
|
8761
|
+
name: "PBKDF2",
|
|
8762
|
+
salt: encodedSalt,
|
|
8763
|
+
hash: "SHA-256",
|
|
8764
|
+
iterations: 1e5
|
|
8765
|
+
};
|
|
8766
|
+
}
|
|
8767
|
+
default:
|
|
8768
|
+
throw new Error("algorithm ".concat(algorithmName, " is currently unsupported"));
|
|
8769
|
+
}
|
|
8770
|
+
}
|
|
8771
|
+
function deriveKeys(material, salt) {
|
|
8772
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8773
|
+
const algorithmOptions = getAlgoOptions(material.algorithm.name, salt);
|
|
8774
|
+
const encryptionKey = yield crypto.subtle.deriveKey(algorithmOptions, material, {
|
|
8775
|
+
name: ENCRYPTION_ALGORITHM,
|
|
8776
|
+
length: 128
|
|
8777
|
+
}, false, ["encrypt", "decrypt"]);
|
|
8778
|
+
return {
|
|
8779
|
+
material,
|
|
8780
|
+
encryptionKey
|
|
8781
|
+
};
|
|
8782
|
+
});
|
|
8783
|
+
}
|
|
8784
|
+
function createE2EEKey() {
|
|
8785
|
+
return window.crypto.getRandomValues(new Uint8Array(32));
|
|
8786
|
+
}
|
|
8787
|
+
function ratchet(material, salt) {
|
|
8788
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8789
|
+
const algorithmOptions = getAlgoOptions(material.algorithm.name, salt);
|
|
8790
|
+
return crypto.subtle.deriveBits(algorithmOptions, material, 256);
|
|
8791
|
+
});
|
|
8792
|
+
}
|
|
8793
|
+
function needsRbspUnescaping(frameData) {
|
|
8794
|
+
for (var i = 0; i < frameData.length - 3; i++) {
|
|
8795
|
+
if (frameData[i] == 0 && frameData[i + 1] == 0 && frameData[i + 2] == 3) return true;
|
|
8796
|
+
}
|
|
8797
|
+
return false;
|
|
8798
|
+
}
|
|
8799
|
+
function parseRbsp(stream) {
|
|
8800
|
+
const dataOut = [];
|
|
8801
|
+
var length = stream.length;
|
|
8802
|
+
for (var i = 0; i < stream.length; ) {
|
|
8803
|
+
if (length - i >= 3 && !stream[i] && !stream[i + 1] && stream[i + 2] == 3) {
|
|
8804
|
+
dataOut.push(stream[i++]);
|
|
8805
|
+
dataOut.push(stream[i++]);
|
|
8806
|
+
i++;
|
|
8807
|
+
} else {
|
|
8808
|
+
dataOut.push(stream[i++]);
|
|
8809
|
+
}
|
|
8810
|
+
}
|
|
8811
|
+
return new Uint8Array(dataOut);
|
|
8812
|
+
}
|
|
8813
|
+
var kZerosInStartSequence = 2;
|
|
8814
|
+
var kEmulationByte = 3;
|
|
8815
|
+
function writeRbsp(data_in) {
|
|
8816
|
+
const dataOut = [];
|
|
8817
|
+
var numConsecutiveZeros = 0;
|
|
8818
|
+
for (var i = 0; i < data_in.length; ++i) {
|
|
8819
|
+
var byte = data_in[i];
|
|
8820
|
+
if (byte <= kEmulationByte && numConsecutiveZeros >= kZerosInStartSequence) {
|
|
8821
|
+
dataOut.push(kEmulationByte);
|
|
8822
|
+
numConsecutiveZeros = 0;
|
|
8823
|
+
}
|
|
8824
|
+
dataOut.push(byte);
|
|
8825
|
+
if (byte == 0) {
|
|
8826
|
+
++numConsecutiveZeros;
|
|
8827
|
+
} else {
|
|
8828
|
+
numConsecutiveZeros = 0;
|
|
8829
|
+
}
|
|
8830
|
+
}
|
|
8831
|
+
return new Uint8Array(dataOut);
|
|
8832
|
+
}
|
|
8720
8833
|
var BaseKeyProvider = class extends eventsExports.EventEmitter {
|
|
8721
8834
|
constructor() {
|
|
8722
8835
|
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -8760,6 +8873,32 @@ var BaseKeyProvider = class extends eventsExports.EventEmitter {
|
|
|
8760
8873
|
this.emit(KeyProviderEvent.RatchetRequest, participantIdentity, keyIndex);
|
|
8761
8874
|
}
|
|
8762
8875
|
};
|
|
8876
|
+
var ExternalE2EEKeyProvider = class extends BaseKeyProvider {
|
|
8877
|
+
constructor() {
|
|
8878
|
+
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8879
|
+
const opts = Object.assign(Object.assign({}, options), {
|
|
8880
|
+
sharedKey: true,
|
|
8881
|
+
// for a shared key provider failing to decrypt for a specific participant
|
|
8882
|
+
// should not mark the key as invalid, so we accept wrong keys forever
|
|
8883
|
+
// and won't try to auto-ratchet
|
|
8884
|
+
ratchetWindowSize: 0,
|
|
8885
|
+
failureTolerance: -1
|
|
8886
|
+
});
|
|
8887
|
+
super(opts);
|
|
8888
|
+
}
|
|
8889
|
+
/**
|
|
8890
|
+
* Accepts a passphrase that's used to create the crypto keys.
|
|
8891
|
+
* When passing in a string, PBKDF2 is used.
|
|
8892
|
+
* When passing in an Array buffer of cryptographically random numbers, HKDF is being used. (recommended)
|
|
8893
|
+
* @param key
|
|
8894
|
+
*/
|
|
8895
|
+
setKey(key) {
|
|
8896
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8897
|
+
const derivedKey = typeof key === "string" ? yield createKeyMaterialFromString(key) : yield createKeyMaterialFromBuffer(key);
|
|
8898
|
+
this.onSetEncryptionKey(derivedKey);
|
|
8899
|
+
});
|
|
8900
|
+
}
|
|
8901
|
+
};
|
|
8763
8902
|
var LivekitError = class extends Error {
|
|
8764
8903
|
constructor(code, message) {
|
|
8765
8904
|
super(message || "an error has occured");
|
|
@@ -8816,6 +8955,12 @@ var NegotiationError = class extends LivekitError {
|
|
|
8816
8955
|
this.name = "NegotiationError";
|
|
8817
8956
|
}
|
|
8818
8957
|
};
|
|
8958
|
+
var PublishDataError = class extends LivekitError {
|
|
8959
|
+
constructor(message) {
|
|
8960
|
+
super(14, message !== null && message !== void 0 ? message : "unable to publish data");
|
|
8961
|
+
this.name = "PublishDataError";
|
|
8962
|
+
}
|
|
8963
|
+
};
|
|
8819
8964
|
var PublishTrackError = class extends LivekitError {
|
|
8820
8965
|
constructor(message, status) {
|
|
8821
8966
|
super(15, message);
|
|
@@ -8860,6 +9005,15 @@ var CryptorErrorReason;
|
|
|
8860
9005
|
CryptorErrorReason2[CryptorErrorReason2["MissingKey"] = 1] = "MissingKey";
|
|
8861
9006
|
CryptorErrorReason2[CryptorErrorReason2["InternalError"] = 2] = "InternalError";
|
|
8862
9007
|
})(CryptorErrorReason || (CryptorErrorReason = {}));
|
|
9008
|
+
var CryptorError = class extends LivekitError {
|
|
9009
|
+
constructor(message) {
|
|
9010
|
+
let reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CryptorErrorReason.InternalError;
|
|
9011
|
+
let participantIdentity = arguments.length > 2 ? arguments[2] : void 0;
|
|
9012
|
+
super(40, message);
|
|
9013
|
+
this.reason = reason;
|
|
9014
|
+
this.participantIdentity = participantIdentity;
|
|
9015
|
+
}
|
|
9016
|
+
};
|
|
8863
9017
|
var RoomEvent;
|
|
8864
9018
|
(function(RoomEvent2) {
|
|
8865
9019
|
RoomEvent2["Connected"] = "connected";
|
|
@@ -9551,6 +9705,12 @@ function supportsTransceiver() {
|
|
|
9551
9705
|
function supportsAddTrack() {
|
|
9552
9706
|
return "addTrack" in RTCPeerConnection.prototype;
|
|
9553
9707
|
}
|
|
9708
|
+
function supportsAdaptiveStream() {
|
|
9709
|
+
return typeof ResizeObserver !== void 0 && typeof IntersectionObserver !== void 0;
|
|
9710
|
+
}
|
|
9711
|
+
function supportsDynacast() {
|
|
9712
|
+
return supportsTransceiver();
|
|
9713
|
+
}
|
|
9554
9714
|
function supportsAV1() {
|
|
9555
9715
|
if (!("getCapabilities" in RTCRtpSender)) {
|
|
9556
9716
|
return false;
|
|
@@ -9667,8 +9827,8 @@ function isWeb() {
|
|
|
9667
9827
|
function isReactNative() {
|
|
9668
9828
|
return navigator.product == "ReactNative";
|
|
9669
9829
|
}
|
|
9670
|
-
function isCloud(
|
|
9671
|
-
return
|
|
9830
|
+
function isCloud(serverUrl) {
|
|
9831
|
+
return serverUrl.hostname.endsWith(".livekit.cloud") || serverUrl.hostname.endsWith(".livekit.run");
|
|
9672
9832
|
}
|
|
9673
9833
|
function getLKReactNativeInfo() {
|
|
9674
9834
|
if (global && global.LiveKitReactNativeGlobal) {
|
|
@@ -9753,6 +9913,13 @@ function getClientInfo() {
|
|
|
9753
9913
|
}
|
|
9754
9914
|
return info;
|
|
9755
9915
|
}
|
|
9916
|
+
var emptyVideoStreamTrack;
|
|
9917
|
+
function getEmptyVideoStreamTrack() {
|
|
9918
|
+
if (!emptyVideoStreamTrack) {
|
|
9919
|
+
emptyVideoStreamTrack = createDummyVideoStreamTrack();
|
|
9920
|
+
}
|
|
9921
|
+
return emptyVideoStreamTrack.clone();
|
|
9922
|
+
}
|
|
9756
9923
|
function createDummyVideoStreamTrack() {
|
|
9757
9924
|
let width = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 16;
|
|
9758
9925
|
let height = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 16;
|
|
@@ -9986,6 +10153,9 @@ function isRemoteVideoTrack(track) {
|
|
|
9986
10153
|
function isLocalParticipant(p) {
|
|
9987
10154
|
return p.isLocal;
|
|
9988
10155
|
}
|
|
10156
|
+
function isRemoteParticipant(p) {
|
|
10157
|
+
return !p.isLocal;
|
|
10158
|
+
}
|
|
9989
10159
|
function splitUtf8(s, n) {
|
|
9990
10160
|
const result = [];
|
|
9991
10161
|
let encoded = new TextEncoder().encode(s);
|
|
@@ -10360,14 +10530,14 @@ var E2EEManager = class extends eventsExports.EventEmitter {
|
|
|
10360
10530
|
/**
|
|
10361
10531
|
* @internal
|
|
10362
10532
|
*/
|
|
10363
|
-
setup(
|
|
10533
|
+
setup(room) {
|
|
10364
10534
|
if (!isE2EESupported()) {
|
|
10365
10535
|
throw new DeviceUnsupportedError("tried to setup end-to-end encryption on an unsupported browser");
|
|
10366
10536
|
}
|
|
10367
10537
|
livekitLogger.info("setting up e2ee");
|
|
10368
|
-
if (
|
|
10369
|
-
this.room =
|
|
10370
|
-
this.setupEventListeners(
|
|
10538
|
+
if (room !== this.room) {
|
|
10539
|
+
this.room = room;
|
|
10540
|
+
this.setupEventListeners(room, this.keyProvider);
|
|
10371
10541
|
const msg = {
|
|
10372
10542
|
kind: "init",
|
|
10373
10543
|
data: {
|
|
@@ -10407,11 +10577,11 @@ var E2EEManager = class extends eventsExports.EventEmitter {
|
|
|
10407
10577
|
this.postRTPMap(rtpMap);
|
|
10408
10578
|
});
|
|
10409
10579
|
}
|
|
10410
|
-
setupEventListeners(
|
|
10411
|
-
|
|
10412
|
-
|
|
10580
|
+
setupEventListeners(room, keyProvider) {
|
|
10581
|
+
room.on(RoomEvent.TrackPublished, (pub, participant) => this.setParticipantCryptorEnabled(pub.trackInfo.encryption !== Encryption_Type.NONE, participant.identity));
|
|
10582
|
+
room.on(RoomEvent.ConnectionStateChanged, (state) => {
|
|
10413
10583
|
if (state === ConnectionState.Connected) {
|
|
10414
|
-
|
|
10584
|
+
room.remoteParticipants.forEach((participant) => {
|
|
10415
10585
|
participant.trackPublications.forEach((pub) => {
|
|
10416
10586
|
this.setParticipantCryptorEnabled(pub.trackInfo.encryption !== Encryption_Type.NONE, participant.identity);
|
|
10417
10587
|
});
|
|
@@ -10438,7 +10608,7 @@ var E2EEManager = class extends eventsExports.EventEmitter {
|
|
|
10438
10608
|
});
|
|
10439
10609
|
this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled, this.room.localParticipant.identity);
|
|
10440
10610
|
});
|
|
10441
|
-
|
|
10611
|
+
room.localParticipant.on(ParticipantEvent.LocalSenderCreated, (sender, track) => __awaiter(this, void 0, void 0, function* () {
|
|
10442
10612
|
this.setupE2EESender(track, sender);
|
|
10443
10613
|
}));
|
|
10444
10614
|
keyProvider.on(KeyProviderEvent.SetKey, (keyInfo) => this.postKey(keyInfo)).on(KeyProviderEvent.RatchetRequest, (participantId, keyIndex) => this.postRatchetRequest(participantId, keyIndex));
|
|
@@ -10847,15 +11017,15 @@ var SignalClient = class {
|
|
|
10847
11017
|
var _a, _b;
|
|
10848
11018
|
return (_b = (_a = this.loggerContextCb) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : {};
|
|
10849
11019
|
}
|
|
10850
|
-
join(url,
|
|
11020
|
+
join(url, token, opts, abortSignal) {
|
|
10851
11021
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10852
11022
|
this.state = SignalConnectionState.CONNECTING;
|
|
10853
11023
|
this.options = opts;
|
|
10854
|
-
const res = yield this.connect(url,
|
|
11024
|
+
const res = yield this.connect(url, token, opts, abortSignal);
|
|
10855
11025
|
return res;
|
|
10856
11026
|
});
|
|
10857
11027
|
}
|
|
10858
|
-
reconnect(url,
|
|
11028
|
+
reconnect(url, token, sid, reason) {
|
|
10859
11029
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10860
11030
|
if (!this.options) {
|
|
10861
11031
|
this.log.warn("attempted to reconnect without signal options being set, ignoring", this.logContext);
|
|
@@ -10863,7 +11033,7 @@ var SignalClient = class {
|
|
|
10863
11033
|
}
|
|
10864
11034
|
this.state = SignalConnectionState.RECONNECTING;
|
|
10865
11035
|
this.clearPingInterval();
|
|
10866
|
-
const res = yield this.connect(url,
|
|
11036
|
+
const res = yield this.connect(url, token, Object.assign(Object.assign({}, this.options), {
|
|
10867
11037
|
reconnect: true,
|
|
10868
11038
|
sid,
|
|
10869
11039
|
reconnectReason: reason
|
|
@@ -10871,10 +11041,10 @@ var SignalClient = class {
|
|
|
10871
11041
|
return res;
|
|
10872
11042
|
});
|
|
10873
11043
|
}
|
|
10874
|
-
connect(url,
|
|
11044
|
+
connect(url, token, opts, abortSignal) {
|
|
10875
11045
|
this.connectOptions = opts;
|
|
10876
11046
|
const clientInfo = getClientInfo();
|
|
10877
|
-
const params = createConnectionParams(
|
|
11047
|
+
const params = createConnectionParams(token, clientInfo, opts);
|
|
10878
11048
|
const rtcUrl = createRtcUrl(url, params);
|
|
10879
11049
|
const validateUrl = createValidateUrl(rtcUrl);
|
|
10880
11050
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -11416,10 +11586,10 @@ function toProtoSessionDescription(rsd, id) {
|
|
|
11416
11586
|
});
|
|
11417
11587
|
return sd;
|
|
11418
11588
|
}
|
|
11419
|
-
function createConnectionParams(
|
|
11589
|
+
function createConnectionParams(token, info, opts) {
|
|
11420
11590
|
var _a;
|
|
11421
11591
|
const params = new URLSearchParams();
|
|
11422
|
-
params.set("access_token",
|
|
11592
|
+
params.set("access_token", token);
|
|
11423
11593
|
if (opts.reconnect) {
|
|
11424
11594
|
params.set("reconnect", "1");
|
|
11425
11595
|
if (opts.sid) {
|
|
@@ -15275,16 +15445,16 @@ var RTCEngine = class extends eventsExports.EventEmitter {
|
|
|
15275
15445
|
pID: this.participantSid
|
|
15276
15446
|
};
|
|
15277
15447
|
}
|
|
15278
|
-
join(url,
|
|
15448
|
+
join(url, token, opts, abortSignal) {
|
|
15279
15449
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15280
15450
|
this.url = url;
|
|
15281
|
-
this.token =
|
|
15451
|
+
this.token = token;
|
|
15282
15452
|
this.signalOpts = opts;
|
|
15283
15453
|
this.maxJoinAttempts = opts.maxRetries;
|
|
15284
15454
|
try {
|
|
15285
15455
|
this.joinAttempts += 1;
|
|
15286
15456
|
this.setupSignalClientCallbacks();
|
|
15287
|
-
const joinResponse = yield this.client.join(url,
|
|
15457
|
+
const joinResponse = yield this.client.join(url, token, opts, abortSignal);
|
|
15288
15458
|
this._isClosed = false;
|
|
15289
15459
|
this.latestJoinResponse = joinResponse;
|
|
15290
15460
|
this.subscriberPrimary = joinResponse.subscriberPrimary;
|
|
@@ -15302,7 +15472,7 @@ var RTCEngine = class extends eventsExports.EventEmitter {
|
|
|
15302
15472
|
if (e2.reason === ConnectionErrorReason.ServerUnreachable) {
|
|
15303
15473
|
this.log.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts, " of ").concat(this.maxJoinAttempts), this.logContext);
|
|
15304
15474
|
if (this.joinAttempts < this.maxJoinAttempts) {
|
|
15305
|
-
return this.join(url,
|
|
15475
|
+
return this.join(url, token, opts, abortSignal);
|
|
15306
15476
|
}
|
|
15307
15477
|
}
|
|
15308
15478
|
}
|
|
@@ -15532,8 +15702,8 @@ var RTCEngine = class extends eventsExports.EventEmitter {
|
|
|
15532
15702
|
this.client.onLocalTrackSubscribed = (trackSid) => {
|
|
15533
15703
|
this.emit(EngineEvent.LocalTrackSubscribed, trackSid);
|
|
15534
15704
|
};
|
|
15535
|
-
this.client.onTokenRefresh = (
|
|
15536
|
-
this.token =
|
|
15705
|
+
this.client.onTokenRefresh = (token) => {
|
|
15706
|
+
this.token = token;
|
|
15537
15707
|
};
|
|
15538
15708
|
this.client.onRemoteMuteChanged = (trackSid, muted) => {
|
|
15539
15709
|
this.emit(EngineEvent.RemoteMute, trackSid, muted);
|
|
@@ -16220,15 +16390,15 @@ function applyUserDataCompat(newObj, oldObj) {
|
|
|
16220
16390
|
oldObj.destinationIdentities = destinationIdentities;
|
|
16221
16391
|
}
|
|
16222
16392
|
var RegionUrlProvider = class {
|
|
16223
|
-
constructor(url,
|
|
16393
|
+
constructor(url, token) {
|
|
16224
16394
|
this.lastUpdateAt = 0;
|
|
16225
16395
|
this.settingsCacheTime = 3e3;
|
|
16226
16396
|
this.attemptedRegions = [];
|
|
16227
16397
|
this.serverUrl = new URL(url);
|
|
16228
|
-
this.token =
|
|
16398
|
+
this.token = token;
|
|
16229
16399
|
}
|
|
16230
|
-
updateToken(
|
|
16231
|
-
this.token =
|
|
16400
|
+
updateToken(token) {
|
|
16401
|
+
this.token = token;
|
|
16232
16402
|
}
|
|
16233
16403
|
isCloud() {
|
|
16234
16404
|
return isCloud(this.serverUrl);
|
|
@@ -16281,8 +16451,8 @@ var RegionUrlProvider = class {
|
|
|
16281
16451
|
this.lastUpdateAt = Date.now();
|
|
16282
16452
|
}
|
|
16283
16453
|
};
|
|
16284
|
-
function getCloudConfigUrl(
|
|
16285
|
-
return "".concat(
|
|
16454
|
+
function getCloudConfigUrl(serverUrl) {
|
|
16455
|
+
return "".concat(serverUrl.protocol.replace("ws", "http"), "//").concat(serverUrl.host, "/settings");
|
|
16286
16456
|
}
|
|
16287
16457
|
var BaseStreamReader = class {
|
|
16288
16458
|
get info() {
|
|
@@ -17445,6 +17615,34 @@ function createLocalAudioTrack(options) {
|
|
|
17445
17615
|
return tracks[0];
|
|
17446
17616
|
});
|
|
17447
17617
|
}
|
|
17618
|
+
function createLocalScreenTracks(options) {
|
|
17619
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17620
|
+
if (options === void 0) {
|
|
17621
|
+
options = {};
|
|
17622
|
+
}
|
|
17623
|
+
if (options.resolution === void 0 && !isSafari17Based()) {
|
|
17624
|
+
options.resolution = ScreenSharePresets.h1080fps30.resolution;
|
|
17625
|
+
}
|
|
17626
|
+
if (navigator.mediaDevices.getDisplayMedia === void 0) {
|
|
17627
|
+
throw new DeviceUnsupportedError("getDisplayMedia not supported");
|
|
17628
|
+
}
|
|
17629
|
+
const constraints = screenCaptureToDisplayMediaStreamOptions(options);
|
|
17630
|
+
const stream = yield navigator.mediaDevices.getDisplayMedia(constraints);
|
|
17631
|
+
const tracks = stream.getVideoTracks();
|
|
17632
|
+
if (tracks.length === 0) {
|
|
17633
|
+
throw new TrackInvalidError("no video track found");
|
|
17634
|
+
}
|
|
17635
|
+
const screenVideo = new LocalVideoTrack(tracks[0], void 0, false);
|
|
17636
|
+
screenVideo.source = Track.Source.ScreenShare;
|
|
17637
|
+
const localTracks = [screenVideo];
|
|
17638
|
+
if (stream.getAudioTracks().length > 0) {
|
|
17639
|
+
const screenAudio = new LocalAudioTrack(stream.getAudioTracks()[0], void 0, false);
|
|
17640
|
+
screenAudio.source = Track.Source.ScreenShareAudio;
|
|
17641
|
+
localTracks.push(screenAudio);
|
|
17642
|
+
}
|
|
17643
|
+
return localTracks;
|
|
17644
|
+
});
|
|
17645
|
+
}
|
|
17448
17646
|
var ConnectionQuality;
|
|
17449
17647
|
(function(ConnectionQuality2) {
|
|
17450
17648
|
ConnectionQuality2["Excellent"] = "excellent";
|
|
@@ -20121,7 +20319,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20121
20319
|
this.byteStreamHandlers = /* @__PURE__ */ new Map();
|
|
20122
20320
|
this.textStreamHandlers = /* @__PURE__ */ new Map();
|
|
20123
20321
|
this.rpcHandlers = /* @__PURE__ */ new Map();
|
|
20124
|
-
this.connect = (url,
|
|
20322
|
+
this.connect = (url, token, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
20125
20323
|
var _a2;
|
|
20126
20324
|
if (!isBrowserSupported()) {
|
|
20127
20325
|
if (isReactNative()) {
|
|
@@ -20147,9 +20345,9 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20147
20345
|
}
|
|
20148
20346
|
if (isCloud(new URL(url))) {
|
|
20149
20347
|
if (this.regionUrlProvider === void 0) {
|
|
20150
|
-
this.regionUrlProvider = new RegionUrlProvider(url,
|
|
20348
|
+
this.regionUrlProvider = new RegionUrlProvider(url, token);
|
|
20151
20349
|
} else {
|
|
20152
|
-
this.regionUrlProvider.updateToken(
|
|
20350
|
+
this.regionUrlProvider.updateToken(token);
|
|
20153
20351
|
}
|
|
20154
20352
|
this.regionUrlProvider.fetchRegionSettings().then((settings) => {
|
|
20155
20353
|
var _a3;
|
|
@@ -20169,7 +20367,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20169
20367
|
this.abortController = abortController;
|
|
20170
20368
|
unlockDisconnect === null || unlockDisconnect === void 0 ? void 0 : unlockDisconnect();
|
|
20171
20369
|
try {
|
|
20172
|
-
yield this.attemptConnection(regionUrl2 !== null && regionUrl2 !== void 0 ? regionUrl2 : url,
|
|
20370
|
+
yield this.attemptConnection(regionUrl2 !== null && regionUrl2 !== void 0 ? regionUrl2 : url, token, opts, abortController);
|
|
20173
20371
|
this.abortController = void 0;
|
|
20174
20372
|
resolve();
|
|
20175
20373
|
} catch (e2) {
|
|
@@ -20211,9 +20409,9 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20211
20409
|
});
|
|
20212
20410
|
return this.connectFuture.promise;
|
|
20213
20411
|
});
|
|
20214
|
-
this.connectSignal = (url,
|
|
20412
|
+
this.connectSignal = (url, token, engine, connectOptions, roomOptions, abortController) => __awaiter(this, void 0, void 0, function* () {
|
|
20215
20413
|
var _a2, _b2, _c2;
|
|
20216
|
-
const joinResponse = yield engine.join(url,
|
|
20414
|
+
const joinResponse = yield engine.join(url, token, {
|
|
20217
20415
|
autoSubscribe: connectOptions.autoSubscribe,
|
|
20218
20416
|
adaptiveStream: typeof roomOptions.adaptiveStream === "object" ? true : roomOptions.adaptiveStream,
|
|
20219
20417
|
maxRetries: connectOptions.maxRetries,
|
|
@@ -20264,7 +20462,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20264
20462
|
this.handleRoomUpdate(joinResponse.room);
|
|
20265
20463
|
}
|
|
20266
20464
|
};
|
|
20267
|
-
this.attemptConnection = (url,
|
|
20465
|
+
this.attemptConnection = (url, token, opts, abortController) => __awaiter(this, void 0, void 0, function* () {
|
|
20268
20466
|
var _a2, _b2;
|
|
20269
20467
|
if (this.state === ConnectionState.Reconnecting || this.isResuming || ((_a2 = this.engine) === null || _a2 === void 0 ? void 0 : _a2.pendingReconnect)) {
|
|
20270
20468
|
this.log.info("Reconnection attempt replaced by new connection attempt", this.logContext);
|
|
@@ -20284,7 +20482,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20284
20482
|
this.engine.peerConnectionTimeout = this.connOptions.peerConnectionTimeout;
|
|
20285
20483
|
}
|
|
20286
20484
|
try {
|
|
20287
|
-
const joinResponse = yield this.connectSignal(url,
|
|
20485
|
+
const joinResponse = yield this.connectSignal(url, token, this.engine, this.connOptions, this.options, abortController);
|
|
20288
20486
|
this.applyJoinResponse(joinResponse);
|
|
20289
20487
|
this.setupLocalParticipantEvents();
|
|
20290
20488
|
this.emit(RoomEvent.SignalConnected);
|
|
@@ -20680,14 +20878,14 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20680
20878
|
}
|
|
20681
20879
|
this.emit(RoomEvent.MediaDevicesChanged);
|
|
20682
20880
|
});
|
|
20683
|
-
this.handleRoomUpdate = (
|
|
20881
|
+
this.handleRoomUpdate = (room) => {
|
|
20684
20882
|
const oldRoom = this.roomInfo;
|
|
20685
|
-
this.roomInfo =
|
|
20686
|
-
if (oldRoom && oldRoom.metadata !==
|
|
20687
|
-
this.emitWhenConnected(RoomEvent.RoomMetadataChanged,
|
|
20883
|
+
this.roomInfo = room;
|
|
20884
|
+
if (oldRoom && oldRoom.metadata !== room.metadata) {
|
|
20885
|
+
this.emitWhenConnected(RoomEvent.RoomMetadataChanged, room.metadata);
|
|
20688
20886
|
}
|
|
20689
|
-
if ((oldRoom === null || oldRoom === void 0 ? void 0 : oldRoom.activeRecording) !==
|
|
20690
|
-
this.emitWhenConnected(RoomEvent.RecordingStatusChanged,
|
|
20887
|
+
if ((oldRoom === null || oldRoom === void 0 ? void 0 : oldRoom.activeRecording) !== room.activeRecording) {
|
|
20888
|
+
this.emitWhenConnected(RoomEvent.RecordingStatusChanged, room.activeRecording);
|
|
20691
20889
|
}
|
|
20692
20890
|
};
|
|
20693
20891
|
this.handleConnectionQualityUpdate = (update) => {
|
|
@@ -21084,15 +21282,15 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
21084
21282
|
* With LiveKit Cloud, it will also determine the best edge data center for
|
|
21085
21283
|
* the current client to connect to if a token is provided.
|
|
21086
21284
|
*/
|
|
21087
|
-
prepareConnection(url,
|
|
21285
|
+
prepareConnection(url, token) {
|
|
21088
21286
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21089
21287
|
if (this.state !== ConnectionState.Disconnected) {
|
|
21090
21288
|
return;
|
|
21091
21289
|
}
|
|
21092
21290
|
this.log.debug("prepareConnection to ".concat(url), this.logContext);
|
|
21093
21291
|
try {
|
|
21094
|
-
if (isCloud(new URL(url)) &&
|
|
21095
|
-
this.regionUrlProvider = new RegionUrlProvider(url,
|
|
21292
|
+
if (isCloud(new URL(url)) && token) {
|
|
21293
|
+
this.regionUrlProvider = new RegionUrlProvider(url, token);
|
|
21096
21294
|
const regionUrl = yield this.regionUrlProvider.getNextBestRegionUrl();
|
|
21097
21295
|
if (regionUrl && this.state === ConnectionState.Disconnected) {
|
|
21098
21296
|
this.regionUrl = regionUrl;
|
|
@@ -21950,6 +22148,24 @@ function mapArgs(args) {
|
|
|
21950
22148
|
return arg;
|
|
21951
22149
|
});
|
|
21952
22150
|
}
|
|
22151
|
+
var Convert = class {
|
|
22152
|
+
static toAgentAttributes(json) {
|
|
22153
|
+
return JSON.parse(json);
|
|
22154
|
+
}
|
|
22155
|
+
static agentAttributesToJson(value) {
|
|
22156
|
+
return JSON.stringify(value);
|
|
22157
|
+
}
|
|
22158
|
+
static toTranscriptionAttributes(json) {
|
|
22159
|
+
return JSON.parse(json);
|
|
22160
|
+
}
|
|
22161
|
+
static transcriptionAttributesToJson(value) {
|
|
22162
|
+
return JSON.stringify(value);
|
|
22163
|
+
}
|
|
22164
|
+
};
|
|
22165
|
+
var attributeTypings = /* @__PURE__ */ Object.freeze({
|
|
22166
|
+
__proto__: null,
|
|
22167
|
+
Convert
|
|
22168
|
+
});
|
|
21953
22169
|
var CheckStatus;
|
|
21954
22170
|
(function(CheckStatus2) {
|
|
21955
22171
|
CheckStatus2[CheckStatus2["IDLE"] = 0] = "IDLE";
|
|
@@ -21959,14 +22175,14 @@ var CheckStatus;
|
|
|
21959
22175
|
CheckStatus2[CheckStatus2["FAILED"] = 4] = "FAILED";
|
|
21960
22176
|
})(CheckStatus || (CheckStatus = {}));
|
|
21961
22177
|
var Checker = class extends eventsExports.EventEmitter {
|
|
21962
|
-
constructor(url,
|
|
22178
|
+
constructor(url, token) {
|
|
21963
22179
|
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
21964
22180
|
super();
|
|
21965
22181
|
this.status = CheckStatus.IDLE;
|
|
21966
22182
|
this.logs = [];
|
|
21967
22183
|
this.options = {};
|
|
21968
22184
|
this.url = url;
|
|
21969
|
-
this.token =
|
|
22185
|
+
this.token = token;
|
|
21970
22186
|
this.name = this.constructor.name;
|
|
21971
22187
|
this.room = new Room(options.roomOptions);
|
|
21972
22188
|
this.connectOptions = options.connectOptions;
|
|
@@ -22278,14 +22494,14 @@ var PublishAudioCheck = class extends Checker {
|
|
|
22278
22494
|
perform() {
|
|
22279
22495
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22280
22496
|
var _a;
|
|
22281
|
-
const
|
|
22497
|
+
const room = yield this.connect();
|
|
22282
22498
|
const track = yield createLocalAudioTrack();
|
|
22283
22499
|
const trackIsSilent = yield detectSilence(track, 1e3);
|
|
22284
22500
|
if (trackIsSilent) {
|
|
22285
22501
|
throw new Error("unable to detect audio from microphone");
|
|
22286
22502
|
}
|
|
22287
22503
|
this.appendMessage("detected audio from microphone");
|
|
22288
|
-
|
|
22504
|
+
room.localParticipant.publishTrack(track);
|
|
22289
22505
|
yield new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
22290
22506
|
const stats = yield (_a = track.sender) === null || _a === void 0 ? void 0 : _a.getStats();
|
|
22291
22507
|
if (!stats) {
|
|
@@ -22311,10 +22527,10 @@ var PublishVideoCheck = class extends Checker {
|
|
|
22311
22527
|
perform() {
|
|
22312
22528
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22313
22529
|
var _a;
|
|
22314
|
-
const
|
|
22530
|
+
const room = yield this.connect();
|
|
22315
22531
|
const track = yield createLocalVideoTrack();
|
|
22316
22532
|
yield this.checkForVideo(track.mediaStreamTrack);
|
|
22317
|
-
|
|
22533
|
+
room.localParticipant.publishTrack(track);
|
|
22318
22534
|
yield new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
22319
22535
|
const stats = yield (_a = track.sender) === null || _a === void 0 ? void 0 : _a.getStats();
|
|
22320
22536
|
if (!stats) {
|
|
@@ -22382,30 +22598,30 @@ var ReconnectCheck = class extends Checker {
|
|
|
22382
22598
|
perform() {
|
|
22383
22599
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22384
22600
|
var _a;
|
|
22385
|
-
const
|
|
22601
|
+
const room = yield this.connect();
|
|
22386
22602
|
let reconnectingTriggered = false;
|
|
22387
22603
|
let reconnected = false;
|
|
22388
22604
|
let reconnectResolver;
|
|
22389
|
-
const
|
|
22605
|
+
const reconnectTimeout = new Promise((resolve) => {
|
|
22390
22606
|
setTimeout(resolve, 5e3);
|
|
22391
22607
|
reconnectResolver = resolve;
|
|
22392
22608
|
});
|
|
22393
22609
|
const handleReconnecting = () => {
|
|
22394
22610
|
reconnectingTriggered = true;
|
|
22395
22611
|
};
|
|
22396
|
-
|
|
22612
|
+
room.on(RoomEvent.SignalReconnecting, handleReconnecting).on(RoomEvent.Reconnecting, handleReconnecting).on(RoomEvent.Reconnected, () => {
|
|
22397
22613
|
reconnected = true;
|
|
22398
22614
|
reconnectResolver(true);
|
|
22399
22615
|
});
|
|
22400
|
-
(_a =
|
|
22401
|
-
const onClose =
|
|
22616
|
+
(_a = room.engine.client.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
22617
|
+
const onClose = room.engine.client.onClose;
|
|
22402
22618
|
if (onClose) {
|
|
22403
22619
|
onClose("");
|
|
22404
22620
|
}
|
|
22405
|
-
yield
|
|
22621
|
+
yield reconnectTimeout;
|
|
22406
22622
|
if (!reconnectingTriggered) {
|
|
22407
22623
|
throw new Error("Did not attempt to reconnect");
|
|
22408
|
-
} else if (!reconnected ||
|
|
22624
|
+
} else if (!reconnected || room.state !== ConnectionState.Connected) {
|
|
22409
22625
|
this.appendWarning("reconnection is only possible in Redis-based configurations");
|
|
22410
22626
|
throw new Error("Not able to reconnect");
|
|
22411
22627
|
}
|
|
@@ -22562,13 +22778,13 @@ var WebSocketCheck = class extends Checker {
|
|
|
22562
22778
|
}
|
|
22563
22779
|
};
|
|
22564
22780
|
var ConnectionCheck = class extends eventsExports.EventEmitter {
|
|
22565
|
-
constructor(url,
|
|
22781
|
+
constructor(url, token) {
|
|
22566
22782
|
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
22567
22783
|
super();
|
|
22568
22784
|
this.options = {};
|
|
22569
22785
|
this.checkResults = /* @__PURE__ */ new Map();
|
|
22570
22786
|
this.url = url;
|
|
22571
|
-
this.token =
|
|
22787
|
+
this.token = token;
|
|
22572
22788
|
this.options = options;
|
|
22573
22789
|
}
|
|
22574
22790
|
getNextCheckId() {
|
|
@@ -22650,758 +22866,172 @@ var ConnectionCheck = class extends eventsExports.EventEmitter {
|
|
|
22650
22866
|
});
|
|
22651
22867
|
}
|
|
22652
22868
|
};
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
var
|
|
22656
|
-
|
|
22657
|
-
|
|
22658
|
-
|
|
22659
|
-
|
|
22660
|
-
|
|
22661
|
-
isConnected: false,
|
|
22662
|
-
isConnecting: false,
|
|
22663
|
-
participants: []
|
|
22664
|
-
};
|
|
22665
|
-
var setWebRTCConfig = (config) => _webRTCConfig = config;
|
|
22666
|
-
var setWebRTCConnectionState = (state) => {
|
|
22667
|
-
_webRTCConnectionState = { ..._webRTCConnectionState, ...state };
|
|
22668
|
-
};
|
|
22669
|
-
|
|
22670
|
-
// src/constants/index.ts
|
|
22671
|
-
var WEBRTC_BACKEND_SERVER_URL = "https://api-webrtc-dev.ansyr.ai";
|
|
22672
|
-
|
|
22673
|
-
// src/utils/jsx-encoder.ts
|
|
22674
|
-
function generateStableDOMId(element) {
|
|
22675
|
-
const tagName = element.tagName.toLowerCase();
|
|
22676
|
-
const text = (element.textContent || "").trim().substring(0, 50);
|
|
22677
|
-
let sibling = element.previousElementSibling;
|
|
22678
|
-
let position = 1;
|
|
22679
|
-
while (sibling) {
|
|
22680
|
-
if (sibling.tagName === element.tagName) {
|
|
22681
|
-
position++;
|
|
22682
|
-
}
|
|
22683
|
-
sibling = sibling.previousElementSibling;
|
|
22684
|
-
}
|
|
22685
|
-
const path = getElementPath(element);
|
|
22686
|
-
const idString = `${tagName}[${position}]_(${text})_${path}`;
|
|
22687
|
-
let hash = 0;
|
|
22688
|
-
for (let i = 0; i < idString.length; i++) {
|
|
22689
|
-
const char = idString.charCodeAt(i);
|
|
22690
|
-
hash = (hash << 5) - hash + char;
|
|
22691
|
-
hash |= 0;
|
|
22692
|
-
}
|
|
22693
|
-
return hash.toString(36);
|
|
22694
|
-
}
|
|
22695
|
-
function getElementPath(element) {
|
|
22696
|
-
if (element.id) {
|
|
22697
|
-
return `id(${element.id})`;
|
|
22698
|
-
}
|
|
22699
|
-
if (element.tagName.toLowerCase() === "body") {
|
|
22700
|
-
return "/body";
|
|
22701
|
-
}
|
|
22702
|
-
let ix = 0;
|
|
22703
|
-
const siblings = element.parentNode?.children || new HTMLCollection();
|
|
22704
|
-
for (let i = 0; i < siblings.length; i++) {
|
|
22705
|
-
const sibling = siblings[i];
|
|
22706
|
-
if (sibling === element) {
|
|
22707
|
-
return `${getElementPath(element.parentNode)}/${element.tagName}[${ix + 1}]`;
|
|
22708
|
-
}
|
|
22709
|
-
if (sibling.nodeType === 1 && sibling.tagName === element.tagName) {
|
|
22710
|
-
ix++;
|
|
22711
|
-
}
|
|
22712
|
-
}
|
|
22713
|
-
return "not_found";
|
|
22714
|
-
}
|
|
22715
|
-
|
|
22716
|
-
// src/core/intent-store.ts
|
|
22717
|
-
var store = {
|
|
22718
|
-
screenMetadata: {},
|
|
22719
|
-
allElementsData: []
|
|
22720
|
-
};
|
|
22721
|
-
var GlobalStore = {
|
|
22722
|
-
// 🔹 Screen Metadata Methods
|
|
22723
|
-
setMetadata(screen, metadata) {
|
|
22724
|
-
store.screenMetadata[screen] = metadata;
|
|
22725
|
-
},
|
|
22726
|
-
getMetadata(screen) {
|
|
22727
|
-
return store.screenMetadata[screen];
|
|
22728
|
-
},
|
|
22729
|
-
clearMetadata(screen) {
|
|
22730
|
-
delete store.screenMetadata[screen];
|
|
22731
|
-
},
|
|
22732
|
-
// 🔹 Generic Store Access Methods
|
|
22733
|
-
setData(key, value) {
|
|
22734
|
-
store[key] = value;
|
|
22735
|
-
},
|
|
22736
|
-
getData(key) {
|
|
22737
|
-
return store[key];
|
|
22738
|
-
},
|
|
22739
|
-
clearData(key) {
|
|
22740
|
-
delete store[key];
|
|
22741
|
-
},
|
|
22742
|
-
// 🔹 Element Data Management
|
|
22743
|
-
setElement(elementData) {
|
|
22744
|
-
const index = store.allElementsData.findIndex((e2) => e2.elementId === elementData.elementId);
|
|
22745
|
-
if (index >= 0) {
|
|
22746
|
-
console.log("Updating existing element");
|
|
22747
|
-
store.allElementsData[index] = elementData;
|
|
22748
|
-
} else {
|
|
22749
|
-
console.log("Adding new element");
|
|
22750
|
-
store.allElementsData.push(elementData);
|
|
22751
|
-
}
|
|
22752
|
-
},
|
|
22753
|
-
getElementById(elementId) {
|
|
22754
|
-
const match = store.allElementsData.find((e2) => e2.elementId === elementId);
|
|
22755
|
-
if (!match) {
|
|
22756
|
-
console.warn(`[GlobalStore] No element found for ID: ${elementId}`);
|
|
22757
|
-
console.log("All elements in store:", store.allElementsData);
|
|
22758
|
-
}
|
|
22759
|
-
return match;
|
|
22760
|
-
},
|
|
22761
|
-
deleteElementById(id) {
|
|
22762
|
-
store.allElementsData = store.allElementsData.filter((e2) => e2.elementId !== id);
|
|
22763
|
-
},
|
|
22764
|
-
clearAllElements() {
|
|
22765
|
-
store.allElementsData = [];
|
|
22766
|
-
}
|
|
22767
|
-
};
|
|
22768
|
-
|
|
22769
|
-
// src/core/navigation.ts
|
|
22770
|
-
var navigation;
|
|
22771
|
-
var navigationHandler = null;
|
|
22772
|
-
function setNavigationHandler(handler) {
|
|
22773
|
-
navigationHandler = handler;
|
|
22774
|
-
}
|
|
22775
|
-
function navigate(path, params) {
|
|
22776
|
-
const safeParams = params || {};
|
|
22777
|
-
const absolutePath = path.startsWith("/") ? path : `/${path}`;
|
|
22778
|
-
if (navigationHandler) {
|
|
22779
|
-
try {
|
|
22780
|
-
navigationHandler(absolutePath, safeParams);
|
|
22781
|
-
} catch (error) {
|
|
22782
|
-
console.error("[CueKit] navigation handler failed, falling back to default:", error);
|
|
22783
|
-
}
|
|
22784
|
-
return;
|
|
22785
|
-
}
|
|
22786
|
-
let fullPath = absolutePath;
|
|
22787
|
-
if (safeParams) {
|
|
22788
|
-
const searchParams = new URLSearchParams(safeParams).toString();
|
|
22789
|
-
if (searchParams) {
|
|
22790
|
-
fullPath += `?${searchParams}`;
|
|
22791
|
-
}
|
|
22792
|
-
}
|
|
22793
|
-
if (navigation) {
|
|
22794
|
-
navigation.push(fullPath);
|
|
22795
|
-
} else {
|
|
22796
|
-
if (typeof window !== "undefined") {
|
|
22797
|
-
window.location.href = fullPath;
|
|
22798
|
-
}
|
|
22799
|
-
}
|
|
22800
|
-
}
|
|
22801
|
-
var getCurrentPath = () => {
|
|
22802
|
-
if (typeof window === "undefined") return "";
|
|
22803
|
-
return window.location.pathname;
|
|
22804
|
-
};
|
|
22805
|
-
var getSearchParams = () => {
|
|
22806
|
-
if (typeof window === "undefined") return new URLSearchParams();
|
|
22807
|
-
return new URLSearchParams(window.location.search);
|
|
22808
|
-
};
|
|
22809
|
-
var safeNavigate = (name, params = {}) => {
|
|
22810
|
-
if (name) {
|
|
22811
|
-
navigate(name, params);
|
|
22812
|
-
} else {
|
|
22813
|
-
console.warn("[CueKit] route name not provided");
|
|
22814
|
-
}
|
|
22815
|
-
};
|
|
22816
|
-
function getCurrentScreenName() {
|
|
22817
|
-
try {
|
|
22818
|
-
const path = getCurrentPath();
|
|
22819
|
-
return path || "UnknownScreen";
|
|
22820
|
-
} catch (e2) {
|
|
22821
|
-
return "UnknownScreen";
|
|
22822
|
-
}
|
|
22823
|
-
}
|
|
22824
|
-
function getCurrentRouteParams() {
|
|
22825
|
-
try {
|
|
22826
|
-
const params = {};
|
|
22827
|
-
const searchParams = getSearchParams();
|
|
22828
|
-
if (searchParams instanceof URLSearchParams) {
|
|
22829
|
-
searchParams.forEach((value, key) => {
|
|
22830
|
-
params[key] = value;
|
|
22831
|
-
});
|
|
22832
|
-
} else {
|
|
22833
|
-
return searchParams;
|
|
22834
|
-
}
|
|
22835
|
-
return params;
|
|
22836
|
-
} catch (e2) {
|
|
22837
|
-
return {};
|
|
22838
|
-
}
|
|
22839
|
-
}
|
|
22840
|
-
function onStateChange() {
|
|
22841
|
-
const routeName = getCurrentScreenName();
|
|
22842
|
-
const params = getCurrentRouteParams();
|
|
22843
|
-
if (params && params.metadata) {
|
|
22844
|
-
try {
|
|
22845
|
-
const metadata = JSON.parse(params.metadata);
|
|
22846
|
-
GlobalStore.setMetadata(routeName, metadata);
|
|
22847
|
-
} catch (error) {
|
|
22848
|
-
console.error("Failed to parse metadata from URL:", error);
|
|
22849
|
-
}
|
|
22850
|
-
}
|
|
22851
|
-
}
|
|
22852
|
-
var handleNavigationAndClick = (routeName, elementHash) => {
|
|
22853
|
-
safeNavigate(routeName);
|
|
22854
|
-
if (typeof MutationObserver === "undefined" || typeof document === "undefined") return;
|
|
22855
|
-
const observer = new MutationObserver((mutationsList, observer2) => {
|
|
22856
|
-
setTimeout(() => {
|
|
22857
|
-
const allElements = document.querySelectorAll("*");
|
|
22858
|
-
let elementToClick = null;
|
|
22859
|
-
for (const element of allElements) {
|
|
22860
|
-
if (element instanceof HTMLElement) {
|
|
22861
|
-
const tagName = element.tagName.toLowerCase();
|
|
22862
|
-
const text = (element.textContent || "").trim().substring(0, 50);
|
|
22863
|
-
let sibling = element.previousElementSibling;
|
|
22864
|
-
let position = 1;
|
|
22865
|
-
while (sibling) {
|
|
22866
|
-
if (sibling.tagName === element.tagName) {
|
|
22867
|
-
position++;
|
|
22868
|
-
}
|
|
22869
|
-
sibling = sibling.previousElementSibling;
|
|
22870
|
-
}
|
|
22871
|
-
const path = getElementPath2(element);
|
|
22872
|
-
const idString = `${tagName}[${position}]_(${text})_${path}`;
|
|
22873
|
-
let hash = 0;
|
|
22874
|
-
for (let i = 0; i < idString.length; i++) {
|
|
22875
|
-
const char = idString.charCodeAt(i);
|
|
22876
|
-
hash = (hash << 5) - hash + char;
|
|
22877
|
-
hash |= 0;
|
|
22878
|
-
}
|
|
22879
|
-
const elementHashValue = hash.toString(36);
|
|
22880
|
-
if (elementHashValue === elementHash) {
|
|
22881
|
-
elementToClick = element;
|
|
22882
|
-
break;
|
|
22883
|
-
}
|
|
22884
|
-
}
|
|
22885
|
-
}
|
|
22886
|
-
if (elementToClick) {
|
|
22887
|
-
elementToClick.click();
|
|
22888
|
-
observer2.disconnect();
|
|
22889
|
-
}
|
|
22890
|
-
}, 100);
|
|
22891
|
-
});
|
|
22892
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
22893
|
-
};
|
|
22894
|
-
function getElementPath2(element) {
|
|
22895
|
-
if (element.id) {
|
|
22896
|
-
return `id(${element.id})`;
|
|
22897
|
-
}
|
|
22898
|
-
const path = [];
|
|
22899
|
-
let current = element;
|
|
22900
|
-
while (current && current !== document.body) {
|
|
22901
|
-
let index = 1;
|
|
22902
|
-
let sibling = current.previousElementSibling;
|
|
22903
|
-
while (sibling) {
|
|
22904
|
-
if (sibling.tagName === current.tagName) {
|
|
22905
|
-
index++;
|
|
22906
|
-
}
|
|
22907
|
-
sibling = sibling.previousElementSibling;
|
|
22908
|
-
}
|
|
22909
|
-
path.unshift(`${current.tagName.toLowerCase()}[${index}]`);
|
|
22910
|
-
current = current.parentElement;
|
|
22911
|
-
}
|
|
22912
|
-
return path.join("/");
|
|
22913
|
-
}
|
|
22914
|
-
|
|
22915
|
-
// src/utils/element-service.ts
|
|
22916
|
-
var INTERACTIVE_ELEMENT_SELECTOR = 'a, button, input, textarea, select, [role="button"], [onclick]';
|
|
22917
|
-
function getInteractiveElements() {
|
|
22918
|
-
return document.querySelectorAll(INTERACTIVE_ELEMENT_SELECTOR);
|
|
22919
|
-
}
|
|
22920
|
-
function getImmediateText(element) {
|
|
22921
|
-
let text = "";
|
|
22922
|
-
if (element.childNodes) {
|
|
22923
|
-
for (const node of Array.from(element.childNodes)) {
|
|
22924
|
-
if (node.nodeType === 3) {
|
|
22925
|
-
text += node.textContent || "";
|
|
22926
|
-
}
|
|
22927
|
-
}
|
|
22928
|
-
}
|
|
22929
|
-
return text.trim();
|
|
22930
|
-
}
|
|
22931
|
-
function captureFullDOMStructure() {
|
|
22932
|
-
console.log("\u{1F333} Capturing full DOM structure...");
|
|
22933
|
-
const components = [];
|
|
22934
|
-
const interactiveElements = getInteractiveElements();
|
|
22935
|
-
interactiveElements.forEach((element) => {
|
|
22936
|
-
if (element instanceof HTMLElement && !element.closest("[data-cuekit-ignore]")) {
|
|
22937
|
-
const nodeData = buildFlatDOMNode(element);
|
|
22938
|
-
if (nodeData) {
|
|
22939
|
-
components.push(nodeData);
|
|
22940
|
-
}
|
|
22941
|
-
}
|
|
22942
|
-
});
|
|
22943
|
-
const result = { components };
|
|
22944
|
-
console.log("\u{1F333} Full DOM structure captured:", result);
|
|
22945
|
-
return result;
|
|
22946
|
-
}
|
|
22947
|
-
function buildFlatDOMNode(element) {
|
|
22948
|
-
if (element.tagName.toLowerCase() === "script" || element.hasAttribute("data-cuekit-ignore") || element.style.display === "none" || element.style.visibility === "hidden") {
|
|
22949
|
-
return null;
|
|
22950
|
-
}
|
|
22951
|
-
const hash = generateStableDOMId(element);
|
|
22952
|
-
const text = getImmediateText(element).substring(0, 100);
|
|
22953
|
-
const isClickable = isElementClickable(element);
|
|
22954
|
-
const componentType = element.tagName.toLowerCase();
|
|
22955
|
-
return {
|
|
22956
|
-
hash,
|
|
22957
|
-
text,
|
|
22958
|
-
isClickable,
|
|
22959
|
-
componentType,
|
|
22960
|
-
children: []
|
|
22961
|
-
// No children in a flat structure
|
|
22962
|
-
};
|
|
22963
|
-
}
|
|
22964
|
-
function isElementClickable(element) {
|
|
22965
|
-
const interactiveSelectors = [
|
|
22966
|
-
"button",
|
|
22967
|
-
"a",
|
|
22968
|
-
"input",
|
|
22969
|
-
"select",
|
|
22970
|
-
"textarea",
|
|
22971
|
-
'[role="button"]',
|
|
22972
|
-
'[role="link"]',
|
|
22973
|
-
'[role="tab"]',
|
|
22974
|
-
"[data-onclick-id]",
|
|
22975
|
-
"[data-on-press-id]",
|
|
22976
|
-
"[onclick]",
|
|
22977
|
-
"[onmousedown]",
|
|
22978
|
-
"[onmouseup]",
|
|
22979
|
-
"[ontouchstart]",
|
|
22980
|
-
"[ontouchend]",
|
|
22981
|
-
"[onkeydown]",
|
|
22982
|
-
"[onkeyup]",
|
|
22983
|
-
"[onkeypress]"
|
|
22984
|
-
];
|
|
22985
|
-
for (const selector of interactiveSelectors) {
|
|
22986
|
-
if (element.matches(selector)) {
|
|
22987
|
-
return true;
|
|
22988
|
-
}
|
|
22989
|
-
}
|
|
22990
|
-
const hasClickEvents = element.onclick !== null || element.getAttribute("onclick") !== null;
|
|
22991
|
-
const hasInteractiveEvents = element.ontouchstart !== null || element.getAttribute("ontouchstart") !== null || element.ontouchend !== null || element.getAttribute("ontouchend") !== null || element.onkeydown !== null || element.getAttribute("onkeydown") !== null || element.onkeyup !== null || element.getAttribute("onkeyup") !== null || element.onkeypress !== null || element.getAttribute("onkeypress") !== null;
|
|
22992
|
-
const hasPointerCursor = element.style.cursor === "pointer" || getComputedStyle(element).cursor === "pointer";
|
|
22993
|
-
const hasTabIndex = element.hasAttribute("tabindex") && parseInt(element.getAttribute("tabindex") || "0") >= 0;
|
|
22994
|
-
const hasInteractiveDataAttrs = element.hasAttribute("data-clickable") || element.hasAttribute("data-interactive") || element.hasAttribute("data-action") || element.hasAttribute("data-handler");
|
|
22995
|
-
const hasInteractiveAria = element.hasAttribute("aria-pressed") || element.hasAttribute("aria-expanded") || element.hasAttribute("aria-selected") || element.hasAttribute("aria-checked");
|
|
22996
|
-
return hasClickEvents || hasInteractiveEvents || hasPointerCursor || hasTabIndex || hasInteractiveDataAttrs || hasInteractiveAria;
|
|
22997
|
-
}
|
|
22998
|
-
function executeAction(action) {
|
|
22999
|
-
console.log("\u{1F3AF} Executing element action:", action);
|
|
23000
|
-
const { action_type, target_element, target } = action;
|
|
23001
|
-
switch (action_type) {
|
|
23002
|
-
case "click":
|
|
23003
|
-
return clickElement(target_element);
|
|
23004
|
-
case "navigate":
|
|
23005
|
-
return navigateToElement(target_element || target);
|
|
23006
|
-
case "input":
|
|
23007
|
-
case "focus":
|
|
23008
|
-
return focusElement(target_element);
|
|
23009
|
-
case "toggle":
|
|
23010
|
-
return toggleElement(target_element);
|
|
23011
|
-
default:
|
|
23012
|
-
console.warn(`\u26A0\uFE0F Unknown action type: ${action_type}`);
|
|
23013
|
-
return false;
|
|
23014
|
-
}
|
|
23015
|
-
}
|
|
23016
|
-
function getFullDOMStructure() {
|
|
23017
|
-
console.log("\u{1F333} ElementService: Getting full DOM structure...");
|
|
23018
|
-
return captureFullDOMStructure();
|
|
23019
|
-
}
|
|
23020
|
-
function clickElement(elementId) {
|
|
23021
|
-
if (!elementId) {
|
|
23022
|
-
console.warn("\u26A0\uFE0F No element ID provided for click action");
|
|
23023
|
-
return false;
|
|
23024
|
-
}
|
|
23025
|
-
const domStructure = getFullDOMStructure();
|
|
23026
|
-
const elementToClick = findElementById(domStructure, elementId);
|
|
23027
|
-
if (elementToClick) {
|
|
23028
|
-
console.log(`\u{1F3AF} Clicking element: ${elementId}`);
|
|
23029
|
-
const domElement = findDOMElementById(elementId);
|
|
23030
|
-
if (domElement) {
|
|
23031
|
-
domElement.click();
|
|
23032
|
-
return true;
|
|
23033
|
-
}
|
|
23034
|
-
} else {
|
|
23035
|
-
console.warn(`\u26A0\uFE0F Element not found: ${elementId}`);
|
|
23036
|
-
}
|
|
23037
|
-
return false;
|
|
23038
|
-
}
|
|
23039
|
-
function navigateToElement(target) {
|
|
23040
|
-
if (!target) {
|
|
23041
|
-
console.warn("\u26A0\uFE0F No target provided for navigation action");
|
|
23042
|
-
return false;
|
|
23043
|
-
}
|
|
23044
|
-
console.log(`\u{1F9ED} Navigating to: ${target}`);
|
|
23045
|
-
if (target.includes("/") || target.startsWith("http")) {
|
|
23046
|
-
safeNavigate(target, {});
|
|
23047
|
-
} else {
|
|
23048
|
-
handleNavigationAndClick(target, target);
|
|
23049
|
-
}
|
|
23050
|
-
return true;
|
|
23051
|
-
}
|
|
23052
|
-
function focusElement(elementId) {
|
|
23053
|
-
if (!elementId) {
|
|
23054
|
-
console.warn("\u26A0\uFE0F No element ID provided for focus action");
|
|
23055
|
-
return false;
|
|
23056
|
-
}
|
|
23057
|
-
const domElement = findDOMElementById(elementId);
|
|
23058
|
-
if (domElement instanceof HTMLInputElement || domElement instanceof HTMLTextAreaElement || domElement instanceof HTMLSelectElement) {
|
|
23059
|
-
console.log(`\u{1F4DD} Focusing element: ${elementId}`);
|
|
23060
|
-
domElement.focus();
|
|
23061
|
-
return true;
|
|
23062
|
-
} else {
|
|
23063
|
-
console.warn(`\u26A0\uFE0F Focusable element not found: ${elementId}`);
|
|
23064
|
-
return false;
|
|
23065
|
-
}
|
|
23066
|
-
}
|
|
23067
|
-
function toggleElement(elementId) {
|
|
23068
|
-
if (!elementId) {
|
|
23069
|
-
console.warn("\u26A0\uFE0F No element ID provided for toggle action");
|
|
23070
|
-
return false;
|
|
23071
|
-
}
|
|
23072
|
-
const domElement = findDOMElementById(elementId);
|
|
23073
|
-
if (domElement instanceof HTMLElement) {
|
|
23074
|
-
console.log(`\u{1F504} Toggling element: ${elementId}`);
|
|
23075
|
-
if (domElement instanceof HTMLInputElement) {
|
|
23076
|
-
if (domElement.type === "checkbox") {
|
|
23077
|
-
domElement.checked = !domElement.checked;
|
|
23078
|
-
} else if (domElement.type === "radio") {
|
|
23079
|
-
domElement.checked = true;
|
|
23080
|
-
}
|
|
23081
|
-
domElement.dispatchEvent(new Event("change", { bubbles: true }));
|
|
23082
|
-
} else {
|
|
23083
|
-
domElement.click();
|
|
23084
|
-
}
|
|
23085
|
-
return true;
|
|
23086
|
-
} else {
|
|
23087
|
-
console.warn(`\u26A0\uFE0F Toggleable element not found: ${elementId}`);
|
|
23088
|
-
return false;
|
|
23089
|
-
}
|
|
23090
|
-
}
|
|
23091
|
-
function findElementById(domStructure, elementId) {
|
|
23092
|
-
const searchInComponents = (components) => {
|
|
23093
|
-
for (const component of components) {
|
|
23094
|
-
if (component.hash === elementId) {
|
|
23095
|
-
return component;
|
|
23096
|
-
}
|
|
23097
|
-
if (component.children.length > 0) {
|
|
23098
|
-
const found = searchInComponents(component.children);
|
|
23099
|
-
if (found) return found;
|
|
23100
|
-
}
|
|
23101
|
-
}
|
|
23102
|
-
return null;
|
|
22869
|
+
function facingModeFromLocalTrack(localTrack) {
|
|
22870
|
+
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
22871
|
+
var _a;
|
|
22872
|
+
const track = isLocalTrack(localTrack) ? localTrack.mediaStreamTrack : localTrack;
|
|
22873
|
+
const trackSettings = track.getSettings();
|
|
22874
|
+
let result = {
|
|
22875
|
+
facingMode: (_a = options.defaultFacingMode) !== null && _a !== void 0 ? _a : "user",
|
|
22876
|
+
confidence: "low"
|
|
23103
22877
|
};
|
|
23104
|
-
|
|
23105
|
-
|
|
23106
|
-
|
|
23107
|
-
|
|
23108
|
-
|
|
23109
|
-
if (
|
|
23110
|
-
|
|
23111
|
-
|
|
23112
|
-
|
|
23113
|
-
|
|
23114
|
-
console.log("\u{1F50D} Found element:", element);
|
|
23115
|
-
return element;
|
|
23116
|
-
}
|
|
22878
|
+
if ("facingMode" in trackSettings) {
|
|
22879
|
+
const rawFacingMode = trackSettings.facingMode;
|
|
22880
|
+
livekitLogger.trace("rawFacingMode", {
|
|
22881
|
+
rawFacingMode
|
|
22882
|
+
});
|
|
22883
|
+
if (rawFacingMode && typeof rawFacingMode === "string" && isFacingModeValue(rawFacingMode)) {
|
|
22884
|
+
result = {
|
|
22885
|
+
facingMode: rawFacingMode,
|
|
22886
|
+
confidence: "high"
|
|
22887
|
+
};
|
|
23117
22888
|
}
|
|
23118
22889
|
}
|
|
23119
|
-
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23123
|
-
|
|
23124
|
-
var reconnectTimeout = null;
|
|
23125
|
-
var serverUrl = WEBRTC_BACKEND_SERVER_URL || "https://bdd4c945f073.ngrok-free.app";
|
|
23126
|
-
var callbacks = {};
|
|
23127
|
-
var audioContainerRef = null;
|
|
23128
|
-
var livekitUrl = null;
|
|
23129
|
-
var token = null;
|
|
23130
|
-
var roomName = null;
|
|
23131
|
-
function setServerUrl(url) {
|
|
23132
|
-
serverUrl = url;
|
|
23133
|
-
}
|
|
23134
|
-
function setAudioContainer(newAudioContainerRef) {
|
|
23135
|
-
audioContainerRef = newAudioContainerRef;
|
|
23136
|
-
}
|
|
23137
|
-
function setWebRTCCallbacks(newCallbacks) {
|
|
23138
|
-
callbacks = newCallbacks;
|
|
23139
|
-
}
|
|
23140
|
-
async function authenticate(userIdentity, apiKey, appId) {
|
|
23141
|
-
try {
|
|
23142
|
-
console.log("\u{1F3A4} WebRTCService: Authenticating user...", { userIdentity });
|
|
23143
|
-
const response = await fetch(`${serverUrl}/auth/login`, {
|
|
23144
|
-
method: "POST",
|
|
23145
|
-
headers: {
|
|
23146
|
-
"Content-Type": "application/json",
|
|
23147
|
-
"X-API-Key": apiKey
|
|
23148
|
-
},
|
|
23149
|
-
body: JSON.stringify({
|
|
23150
|
-
user_identity: userIdentity,
|
|
23151
|
-
app_id: appId || _appId
|
|
23152
|
-
})
|
|
23153
|
-
});
|
|
23154
|
-
if (!response.ok) {
|
|
23155
|
-
const errorData = await response.json();
|
|
23156
|
-
throw new Error(errorData.detail || "Authentication failed");
|
|
23157
|
-
}
|
|
23158
|
-
const authData = await response.json();
|
|
23159
|
-
console.log("\u{1F3A4} WebRTCService: Authentication successful:", authData);
|
|
23160
|
-
livekitUrl = authData.livekit_url;
|
|
23161
|
-
token = authData.livekit_token;
|
|
23162
|
-
roomName = authData.room_name;
|
|
23163
|
-
userIdentity = authData.user_identity;
|
|
23164
|
-
return authData;
|
|
23165
|
-
} catch (error) {
|
|
23166
|
-
console.error("\u{1F3A4} WebRTCService: Authentication failed:", error);
|
|
23167
|
-
throw error;
|
|
23168
|
-
}
|
|
23169
|
-
}
|
|
23170
|
-
async function connectToRoom(newLivekitUrl, newToken) {
|
|
23171
|
-
const url = newLivekitUrl || livekitUrl;
|
|
23172
|
-
const authToken = newToken || token;
|
|
23173
|
-
if (!url || !authToken) {
|
|
23174
|
-
throw new Error("Missing LiveKit URL or token. Please authenticate first.");
|
|
23175
|
-
}
|
|
23176
|
-
console.log("\u{1F3A4} WebRTCService: Connecting to room...", { url, hasToken: !!authToken });
|
|
23177
|
-
try {
|
|
23178
|
-
setWebRTCConnectionState({ isConnected: false, isConnecting: true });
|
|
23179
|
-
room = new Room({
|
|
23180
|
-
adaptiveStream: true,
|
|
23181
|
-
dynacast: true
|
|
23182
|
-
});
|
|
23183
|
-
setupEventListeners();
|
|
23184
|
-
await room.connect(url, authToken);
|
|
23185
|
-
console.log("\u{1F3A4} WebRTCService: Successfully connected to room:", room.name);
|
|
23186
|
-
setWebRTCConnectionState({ isConnected: true, isConnecting: false });
|
|
23187
|
-
try {
|
|
23188
|
-
await room.localParticipant.setMicrophoneEnabled(true);
|
|
23189
|
-
console.log("\u{1F3A4} WebRTCService: Microphone enabled");
|
|
23190
|
-
} catch (micError) {
|
|
23191
|
-
console.warn("\u{1F3A4} WebRTCService: Failed to enable microphone:", micError);
|
|
23192
|
-
}
|
|
23193
|
-
return { success: true };
|
|
23194
|
-
} catch (error) {
|
|
23195
|
-
console.error("\u{1F3A4} WebRTCService: Failed to connect to room:", error);
|
|
23196
|
-
setWebRTCConnectionState({ isConnected: false, isConnecting: false });
|
|
23197
|
-
throw error;
|
|
23198
|
-
}
|
|
23199
|
-
}
|
|
23200
|
-
function setupEventListeners() {
|
|
23201
|
-
if (!room) return;
|
|
23202
|
-
room.on(RoomEvent.ConnectionStateChanged, (state) => {
|
|
23203
|
-
console.log("\u{1F3A4} WebRTCService: Connection state changed:", state);
|
|
23204
|
-
callbacks.onConnectionStateChange?.(state);
|
|
23205
|
-
if (state === ConnectionState.Connected) {
|
|
23206
|
-
console.log("\u{1F3A4} WebRTCService: Successfully connected to room");
|
|
23207
|
-
setWebRTCConnectionState({ isConnected: true, isConnecting: false });
|
|
23208
|
-
} else if (state === ConnectionState.Disconnected) {
|
|
23209
|
-
console.log("\u{1F3A4} WebRTCService: Disconnected from room");
|
|
23210
|
-
setWebRTCConnectionState({ isConnected: false, isConnecting: false });
|
|
23211
|
-
} else if (state === ConnectionState.Connecting) {
|
|
23212
|
-
console.log("\u{1F3A4} WebRTCService: Connecting to room...");
|
|
23213
|
-
setWebRTCConnectionState({ isConnected: false, isConnecting: true });
|
|
23214
|
-
}
|
|
23215
|
-
}).on(RoomEvent.ParticipantConnected, (participant) => {
|
|
23216
|
-
console.log("\u{1F3A4} WebRTCService: Participant connected:", participant.identity);
|
|
23217
|
-
updateParticipantsList();
|
|
23218
|
-
}).on(RoomEvent.ParticipantDisconnected, (participant) => {
|
|
23219
|
-
console.log("\u{1F3A4} WebRTCService: Participant disconnected:", participant.identity);
|
|
23220
|
-
updateParticipantsList();
|
|
23221
|
-
}).on(RoomEvent.TrackSubscribed, (track, publication, participant) => {
|
|
23222
|
-
if (track.kind === Track.Kind.Audio && !participant.isLocal) {
|
|
23223
|
-
const isAIParticipant = participant.identity.toLowerCase().includes("ai") || participant.identity.toLowerCase().includes("bot") || !participant.identity.startsWith("user_");
|
|
23224
|
-
if (isAIParticipant) {
|
|
23225
|
-
const element = track.attach();
|
|
23226
|
-
if (audioContainerRef?.current) {
|
|
23227
|
-
audioContainerRef.current.appendChild(element);
|
|
23228
|
-
if (element instanceof HTMLAudioElement) {
|
|
23229
|
-
const trackId = track.sid || `track_${Date.now()}_${Math.random()}`;
|
|
23230
|
-
callbacks.onAISpeechStart?.(trackId);
|
|
23231
|
-
element.play().catch(
|
|
23232
|
-
(error) => console.warn("\u{1F3A4} WebRTCService: Failed to auto-play audio:", error)
|
|
23233
|
-
);
|
|
23234
|
-
element.addEventListener("ended", () => callbacks.onAISpeechEnd?.(trackId));
|
|
23235
|
-
element.addEventListener("pause", () => callbacks.onAISpeechEnd?.(trackId));
|
|
23236
|
-
}
|
|
23237
|
-
}
|
|
23238
|
-
}
|
|
22890
|
+
if (["low", "medium"].includes(result.confidence)) {
|
|
22891
|
+
livekitLogger.trace("Try to get facing mode from device label: (".concat(track.label, ")"));
|
|
22892
|
+
const labelAnalysisResult = facingModeFromDeviceLabel(track.label);
|
|
22893
|
+
if (labelAnalysisResult !== void 0) {
|
|
22894
|
+
result = labelAnalysisResult;
|
|
23239
22895
|
}
|
|
23240
|
-
}).on(RoomEvent.TrackUnsubscribed, (track) => {
|
|
23241
|
-
track.detach().forEach((element) => element.remove());
|
|
23242
|
-
}).on(RoomEvent.DataReceived, (payload, participant) => {
|
|
23243
|
-
console.log("\u{1F4E1} LiveKit data received:", new TextDecoder().decode(payload));
|
|
23244
|
-
try {
|
|
23245
|
-
const message = JSON.parse(new TextDecoder().decode(payload));
|
|
23246
|
-
console.log("\u{1F4E1} LiveKit data received:", message);
|
|
23247
|
-
callbacks.onNavigationCommand?.(message);
|
|
23248
|
-
} catch (error) {
|
|
23249
|
-
const message = new TextDecoder().decode(payload);
|
|
23250
|
-
callbacks.onNavigationCommand?.({ type: "raw_text", data: message });
|
|
23251
|
-
}
|
|
23252
|
-
}).on(RoomEvent.Disconnected, () => {
|
|
23253
|
-
setWebRTCConnectionState({ isConnected: false, isConnecting: false });
|
|
23254
|
-
});
|
|
23255
|
-
}
|
|
23256
|
-
function updateParticipantsList() {
|
|
23257
|
-
if (!room) return;
|
|
23258
|
-
const participants = [
|
|
23259
|
-
room.localParticipant.identity,
|
|
23260
|
-
...Array.from(room.remoteParticipants.values()).map((p) => p.identity)
|
|
23261
|
-
];
|
|
23262
|
-
setWebRTCConnectionState({ participants });
|
|
23263
|
-
callbacks.onParticipantUpdate?.(participants);
|
|
23264
|
-
}
|
|
23265
|
-
async function sendData(data, reliable = true) {
|
|
23266
|
-
if (!room) throw new Error("Not connected to room");
|
|
23267
|
-
try {
|
|
23268
|
-
console.log("\u{1F4E1} LiveKit data sending:", data);
|
|
23269
|
-
const encoder = new TextEncoder();
|
|
23270
|
-
const encodedData = encoder.encode(data);
|
|
23271
|
-
await room.localParticipant.publishData(encodedData, {
|
|
23272
|
-
reliable
|
|
23273
|
-
});
|
|
23274
|
-
} catch (error) {
|
|
23275
|
-
console.error("Error sending data:", error);
|
|
23276
|
-
throw error;
|
|
23277
|
-
}
|
|
23278
|
-
}
|
|
23279
|
-
async function sendScreenStatus(screenData) {
|
|
23280
|
-
try {
|
|
23281
|
-
await fetch(`${serverUrl}/ai/data`, {
|
|
23282
|
-
method: "POST",
|
|
23283
|
-
headers: { "Content-Type": "application/json" },
|
|
23284
|
-
body: JSON.stringify(screenData)
|
|
23285
|
-
});
|
|
23286
|
-
} catch (error) {
|
|
23287
|
-
console.error("Error sending screen status:", error);
|
|
23288
|
-
throw error;
|
|
23289
|
-
}
|
|
23290
|
-
}
|
|
23291
|
-
function isConnected() {
|
|
23292
|
-
return room?.state === ConnectionState.Connected;
|
|
23293
|
-
}
|
|
23294
|
-
function getRoomName() {
|
|
23295
|
-
return roomName;
|
|
23296
|
-
}
|
|
23297
|
-
function getParticipants() {
|
|
23298
|
-
return Array.from(room?.remoteParticipants.values() ?? []);
|
|
23299
|
-
}
|
|
23300
|
-
async function sendUserCommand(command) {
|
|
23301
|
-
if (!room) return;
|
|
23302
|
-
console.log(`\u{1F4AC} Sending user command: "${command}"`);
|
|
23303
|
-
await sendData(command);
|
|
23304
|
-
}
|
|
23305
|
-
async function sendRuntimeData() {
|
|
23306
|
-
if (!room) {
|
|
23307
|
-
console.error("\u274C Cannot send runtime data without a room connection");
|
|
23308
|
-
return;
|
|
23309
|
-
}
|
|
23310
|
-
try {
|
|
23311
|
-
const domStructure = captureFullDOMStructure();
|
|
23312
|
-
const screenName = getCurrentScreenName();
|
|
23313
|
-
const response = {
|
|
23314
|
-
type: "runtime_data_response",
|
|
23315
|
-
data: {
|
|
23316
|
-
components: domStructure.components,
|
|
23317
|
-
current_screen: screenName
|
|
23318
|
-
}
|
|
23319
|
-
};
|
|
23320
|
-
console.log("\u{1F4E6} Sending runtime data response");
|
|
23321
|
-
await sendData(JSON.stringify(response));
|
|
23322
|
-
console.log("\u{1F4E6} Runtime data sent successfully");
|
|
23323
|
-
} catch (error) {
|
|
23324
|
-
console.error("\u274C Failed to send runtime data:", error);
|
|
23325
|
-
}
|
|
23326
|
-
}
|
|
23327
|
-
async function sendStaticData(componentData, appId = "default") {
|
|
23328
|
-
try {
|
|
23329
|
-
const response = await fetch(`${serverUrl}/ai/data`, {
|
|
23330
|
-
method: "POST",
|
|
23331
|
-
headers: {
|
|
23332
|
-
"Content-Type": "application/json"
|
|
23333
|
-
},
|
|
23334
|
-
body: JSON.stringify({
|
|
23335
|
-
type: "dashboard_data",
|
|
23336
|
-
app_id: appId,
|
|
23337
|
-
data: componentData
|
|
23338
|
-
})
|
|
23339
|
-
});
|
|
23340
|
-
if (response.ok) {
|
|
23341
|
-
const result = await response.json();
|
|
23342
|
-
return { success: true, data: result };
|
|
23343
|
-
} else {
|
|
23344
|
-
const errorText = await response.text();
|
|
23345
|
-
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
|
23346
|
-
}
|
|
23347
|
-
} catch (error) {
|
|
23348
|
-
return { success: false, error: error instanceof Error ? error.message : "Network error" };
|
|
23349
22896
|
}
|
|
22897
|
+
return result;
|
|
23350
22898
|
}
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
|
|
22899
|
+
var knownDeviceLabels = /* @__PURE__ */ new Map([["obs virtual camera", {
|
|
22900
|
+
facingMode: "environment",
|
|
22901
|
+
confidence: "medium"
|
|
22902
|
+
}]]);
|
|
22903
|
+
var knownDeviceLabelSections = /* @__PURE__ */ new Map([["iphone", {
|
|
22904
|
+
facingMode: "environment",
|
|
22905
|
+
confidence: "medium"
|
|
22906
|
+
}], ["ipad", {
|
|
22907
|
+
facingMode: "environment",
|
|
22908
|
+
confidence: "medium"
|
|
22909
|
+
}]]);
|
|
22910
|
+
function facingModeFromDeviceLabel(deviceLabel) {
|
|
22911
|
+
var _a;
|
|
22912
|
+
const label = deviceLabel.trim().toLowerCase();
|
|
22913
|
+
if (label === "") {
|
|
22914
|
+
return void 0;
|
|
23355
22915
|
}
|
|
23356
|
-
if (
|
|
23357
|
-
|
|
23358
|
-
reconnectTimeout = null;
|
|
22916
|
+
if (knownDeviceLabels.has(label)) {
|
|
22917
|
+
return knownDeviceLabels.get(label);
|
|
23359
22918
|
}
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
});
|
|
22919
|
+
return (_a = Array.from(knownDeviceLabelSections.entries()).find((_ref) => {
|
|
22920
|
+
let [section] = _ref;
|
|
22921
|
+
return label.includes(section);
|
|
22922
|
+
})) === null || _a === void 0 ? void 0 : _a[1];
|
|
23365
22923
|
}
|
|
23366
|
-
function
|
|
23367
|
-
|
|
22924
|
+
function isFacingModeValue(item) {
|
|
22925
|
+
const allowedValues = ["user", "environment", "left", "right"];
|
|
22926
|
+
return item === void 0 || allowedValues.includes(item);
|
|
23368
22927
|
}
|
|
23369
22928
|
|
|
23370
22929
|
export {
|
|
23371
|
-
|
|
23372
|
-
|
|
23373
|
-
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
22930
|
+
_,
|
|
22931
|
+
TrackType,
|
|
22932
|
+
DisconnectReason,
|
|
22933
|
+
SubscriptionError,
|
|
22934
|
+
ParticipantInfo_Kind,
|
|
22935
|
+
DataPacket_Kind,
|
|
22936
|
+
LogLevel,
|
|
22937
|
+
LoggerNames,
|
|
22938
|
+
getLogger,
|
|
22939
|
+
setLogLevel,
|
|
22940
|
+
setLogExtension,
|
|
22941
|
+
DefaultReconnectPolicy,
|
|
22942
|
+
KeyProviderEvent,
|
|
22943
|
+
KeyHandlerEvent,
|
|
22944
|
+
EncryptionEvent,
|
|
22945
|
+
CryptorEvent,
|
|
22946
|
+
isE2EESupported,
|
|
22947
|
+
isScriptTransformSupported,
|
|
22948
|
+
isInsertableStreamSupported,
|
|
22949
|
+
isVideoFrame,
|
|
22950
|
+
importKey,
|
|
22951
|
+
createKeyMaterialFromString,
|
|
22952
|
+
createKeyMaterialFromBuffer,
|
|
22953
|
+
deriveKeys,
|
|
22954
|
+
createE2EEKey,
|
|
22955
|
+
ratchet,
|
|
22956
|
+
needsRbspUnescaping,
|
|
22957
|
+
parseRbsp,
|
|
22958
|
+
writeRbsp,
|
|
22959
|
+
BaseKeyProvider,
|
|
22960
|
+
ExternalE2EEKeyProvider,
|
|
22961
|
+
LivekitError,
|
|
22962
|
+
ConnectionErrorReason,
|
|
22963
|
+
ConnectionError,
|
|
22964
|
+
DeviceUnsupportedError,
|
|
22965
|
+
TrackInvalidError,
|
|
22966
|
+
UnsupportedServer,
|
|
22967
|
+
UnexpectedConnectionState,
|
|
22968
|
+
NegotiationError,
|
|
22969
|
+
PublishDataError,
|
|
22970
|
+
PublishTrackError,
|
|
22971
|
+
SignalRequestError,
|
|
22972
|
+
MediaDeviceFailure,
|
|
22973
|
+
CryptorErrorReason,
|
|
22974
|
+
CryptorError,
|
|
23383
22975
|
RoomEvent,
|
|
23384
22976
|
ParticipantEvent,
|
|
22977
|
+
EngineEvent,
|
|
22978
|
+
TrackEvent,
|
|
22979
|
+
getBrowser,
|
|
22980
|
+
version,
|
|
22981
|
+
protocolVersion,
|
|
22982
|
+
CriticalTimers,
|
|
22983
|
+
VideoQuality,
|
|
23385
22984
|
Track,
|
|
22985
|
+
attachToElement,
|
|
22986
|
+
detachTrack,
|
|
22987
|
+
VideoPreset,
|
|
22988
|
+
videoCodecs,
|
|
22989
|
+
isBackupCodec,
|
|
22990
|
+
BackupCodecPolicy,
|
|
22991
|
+
AudioPresets,
|
|
22992
|
+
VideoPresets,
|
|
22993
|
+
VideoPresets43,
|
|
22994
|
+
ScreenSharePresets,
|
|
22995
|
+
supportsAdaptiveStream,
|
|
22996
|
+
supportsDynacast,
|
|
22997
|
+
supportsAV1,
|
|
22998
|
+
supportsVP9,
|
|
22999
|
+
isBrowserSupported,
|
|
23000
|
+
compareVersions,
|
|
23001
|
+
getEmptyVideoStreamTrack,
|
|
23002
|
+
getEmptyAudioStreamTrack,
|
|
23386
23003
|
createAudioAnalyser,
|
|
23004
|
+
isLocalTrack,
|
|
23005
|
+
isAudioTrack,
|
|
23006
|
+
isVideoTrack,
|
|
23007
|
+
isRemoteTrack,
|
|
23008
|
+
isLocalParticipant,
|
|
23009
|
+
isRemoteParticipant,
|
|
23010
|
+
RpcError,
|
|
23011
|
+
LocalTrackRecorder,
|
|
23012
|
+
LocalTrack,
|
|
23013
|
+
LocalAudioTrack,
|
|
23014
|
+
LocalVideoTrack,
|
|
23015
|
+
RemoteTrack,
|
|
23016
|
+
RemoteAudioTrack,
|
|
23017
|
+
RemoteVideoTrack,
|
|
23018
|
+
TrackPublication,
|
|
23019
|
+
LocalTrackPublication,
|
|
23020
|
+
createLocalTracks,
|
|
23021
|
+
createLocalVideoTrack,
|
|
23022
|
+
createLocalAudioTrack,
|
|
23023
|
+
createLocalScreenTracks,
|
|
23024
|
+
ConnectionQuality,
|
|
23387
23025
|
Participant,
|
|
23026
|
+
LocalParticipant,
|
|
23027
|
+
RemoteTrackPublication,
|
|
23028
|
+
RemoteParticipant,
|
|
23388
23029
|
ConnectionState,
|
|
23389
|
-
|
|
23390
|
-
|
|
23391
|
-
|
|
23392
|
-
|
|
23393
|
-
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
connectToRoom,
|
|
23397
|
-
sendData,
|
|
23398
|
-
sendScreenStatus,
|
|
23399
|
-
isConnected,
|
|
23400
|
-
getRoomName,
|
|
23401
|
-
getParticipants,
|
|
23402
|
-
sendUserCommand,
|
|
23403
|
-
sendRuntimeData,
|
|
23404
|
-
sendStaticData,
|
|
23405
|
-
disconnectFromRoom,
|
|
23406
|
-
getRoom
|
|
23030
|
+
Room,
|
|
23031
|
+
attributeTypings,
|
|
23032
|
+
CheckStatus,
|
|
23033
|
+
Checker,
|
|
23034
|
+
ConnectionCheck,
|
|
23035
|
+
facingModeFromLocalTrack,
|
|
23036
|
+
facingModeFromDeviceLabel
|
|
23407
23037
|
};
|