@cuekit-ai/react 1.3.2 → 1.3.4
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-H44FBEX3.mjs → chunk-ZGHSIEXZ.mjs} +800 -460
- package/dist/index.d.mts +22 -13
- package/dist/index.d.ts +22 -13
- package/dist/index.js +1137 -917
- package/dist/index.mjs +858 -177
- package/dist/{webrtc-service-TL73OATV.mjs → webrtc-service-SDVOO4LS.mjs} +1 -2
- package/package.json +4 -2
- package/dist/chunk-R7POPVJR.mjs +0 -35
- package/dist/chunk-Y2Q57RZJ.mjs +0 -764
- package/dist/livekit-client.esm-33GHDCYA.mjs +0 -219
|
@@ -1,3 +1,39 @@
|
|
|
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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
|
|
1
37
|
// node_modules/livekit-client/dist/livekit-client.esm.mjs
|
|
2
38
|
function _mergeNamespaces(n, m) {
|
|
3
39
|
m.forEach(function(e2) {
|
|
@@ -5685,34 +5721,6 @@ function getLogger(name) {
|
|
|
5685
5721
|
logger.setDefaultLevel(livekitLogger.getLevel());
|
|
5686
5722
|
return logger;
|
|
5687
5723
|
}
|
|
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
|
-
}
|
|
5716
5724
|
var workerLogger = loglevelExports.getLogger("lk-e2ee");
|
|
5717
5725
|
var maxRetryDelay = 7e3;
|
|
5718
5726
|
var DEFAULT_RETRY_DELAYS_IN_MS = [0, 300, 2 * 2 * 300, 3 * 3 * 300, 4 * 4 * 300, maxRetryDelay, maxRetryDelay, maxRetryDelay, maxRetryDelay, maxRetryDelay];
|
|
@@ -8676,7 +8684,6 @@ function adapterFactory() {
|
|
|
8676
8684
|
adapterFactory({
|
|
8677
8685
|
window: typeof window === "undefined" ? void 0 : window
|
|
8678
8686
|
});
|
|
8679
|
-
var ENCRYPTION_ALGORITHM = "AES-GCM";
|
|
8680
8687
|
var DECRYPTION_FAILURE_TOLERANCE = 10;
|
|
8681
8688
|
var E2EE_FLAG = "lk_e2ee";
|
|
8682
8689
|
var SALT = "LKFrameEncryptionKey";
|
|
@@ -8716,120 +8723,6 @@ function isInsertableStreamSupported() {
|
|
|
8716
8723
|
return typeof window.RTCRtpSender !== "undefined" && // @ts-ignore
|
|
8717
8724
|
typeof window.RTCRtpSender.prototype.createEncodedStreams !== "undefined";
|
|
8718
8725
|
}
|
|
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
|
-
}
|
|
8833
8726
|
var BaseKeyProvider = class extends eventsExports.EventEmitter {
|
|
8834
8727
|
constructor() {
|
|
8835
8728
|
let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -8873,32 +8766,6 @@ var BaseKeyProvider = class extends eventsExports.EventEmitter {
|
|
|
8873
8766
|
this.emit(KeyProviderEvent.RatchetRequest, participantIdentity, keyIndex);
|
|
8874
8767
|
}
|
|
8875
8768
|
};
|
|
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
|
-
};
|
|
8902
8769
|
var LivekitError = class extends Error {
|
|
8903
8770
|
constructor(code, message) {
|
|
8904
8771
|
super(message || "an error has occured");
|
|
@@ -8955,12 +8822,6 @@ var NegotiationError = class extends LivekitError {
|
|
|
8955
8822
|
this.name = "NegotiationError";
|
|
8956
8823
|
}
|
|
8957
8824
|
};
|
|
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
|
-
};
|
|
8964
8825
|
var PublishTrackError = class extends LivekitError {
|
|
8965
8826
|
constructor(message, status) {
|
|
8966
8827
|
super(15, message);
|
|
@@ -9005,15 +8866,6 @@ var CryptorErrorReason;
|
|
|
9005
8866
|
CryptorErrorReason2[CryptorErrorReason2["MissingKey"] = 1] = "MissingKey";
|
|
9006
8867
|
CryptorErrorReason2[CryptorErrorReason2["InternalError"] = 2] = "InternalError";
|
|
9007
8868
|
})(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
|
-
};
|
|
9017
8869
|
var RoomEvent;
|
|
9018
8870
|
(function(RoomEvent2) {
|
|
9019
8871
|
RoomEvent2["Connected"] = "connected";
|
|
@@ -9705,12 +9557,6 @@ function supportsTransceiver() {
|
|
|
9705
9557
|
function supportsAddTrack() {
|
|
9706
9558
|
return "addTrack" in RTCPeerConnection.prototype;
|
|
9707
9559
|
}
|
|
9708
|
-
function supportsAdaptiveStream() {
|
|
9709
|
-
return typeof ResizeObserver !== void 0 && typeof IntersectionObserver !== void 0;
|
|
9710
|
-
}
|
|
9711
|
-
function supportsDynacast() {
|
|
9712
|
-
return supportsTransceiver();
|
|
9713
|
-
}
|
|
9714
9560
|
function supportsAV1() {
|
|
9715
9561
|
if (!("getCapabilities" in RTCRtpSender)) {
|
|
9716
9562
|
return false;
|
|
@@ -9827,8 +9673,8 @@ function isWeb() {
|
|
|
9827
9673
|
function isReactNative() {
|
|
9828
9674
|
return navigator.product == "ReactNative";
|
|
9829
9675
|
}
|
|
9830
|
-
function isCloud(
|
|
9831
|
-
return
|
|
9676
|
+
function isCloud(serverUrl2) {
|
|
9677
|
+
return serverUrl2.hostname.endsWith(".livekit.cloud") || serverUrl2.hostname.endsWith(".livekit.run");
|
|
9832
9678
|
}
|
|
9833
9679
|
function getLKReactNativeInfo() {
|
|
9834
9680
|
if (global && global.LiveKitReactNativeGlobal) {
|
|
@@ -9913,13 +9759,6 @@ function getClientInfo() {
|
|
|
9913
9759
|
}
|
|
9914
9760
|
return info;
|
|
9915
9761
|
}
|
|
9916
|
-
var emptyVideoStreamTrack;
|
|
9917
|
-
function getEmptyVideoStreamTrack() {
|
|
9918
|
-
if (!emptyVideoStreamTrack) {
|
|
9919
|
-
emptyVideoStreamTrack = createDummyVideoStreamTrack();
|
|
9920
|
-
}
|
|
9921
|
-
return emptyVideoStreamTrack.clone();
|
|
9922
|
-
}
|
|
9923
9762
|
function createDummyVideoStreamTrack() {
|
|
9924
9763
|
let width = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 16;
|
|
9925
9764
|
let height = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 16;
|
|
@@ -10153,9 +9992,6 @@ function isRemoteVideoTrack(track) {
|
|
|
10153
9992
|
function isLocalParticipant(p) {
|
|
10154
9993
|
return p.isLocal;
|
|
10155
9994
|
}
|
|
10156
|
-
function isRemoteParticipant(p) {
|
|
10157
|
-
return !p.isLocal;
|
|
10158
|
-
}
|
|
10159
9995
|
function splitUtf8(s, n) {
|
|
10160
9996
|
const result = [];
|
|
10161
9997
|
let encoded = new TextEncoder().encode(s);
|
|
@@ -10530,14 +10366,14 @@ var E2EEManager = class extends eventsExports.EventEmitter {
|
|
|
10530
10366
|
/**
|
|
10531
10367
|
* @internal
|
|
10532
10368
|
*/
|
|
10533
|
-
setup(
|
|
10369
|
+
setup(room2) {
|
|
10534
10370
|
if (!isE2EESupported()) {
|
|
10535
10371
|
throw new DeviceUnsupportedError("tried to setup end-to-end encryption on an unsupported browser");
|
|
10536
10372
|
}
|
|
10537
10373
|
livekitLogger.info("setting up e2ee");
|
|
10538
|
-
if (
|
|
10539
|
-
this.room =
|
|
10540
|
-
this.setupEventListeners(
|
|
10374
|
+
if (room2 !== this.room) {
|
|
10375
|
+
this.room = room2;
|
|
10376
|
+
this.setupEventListeners(room2, this.keyProvider);
|
|
10541
10377
|
const msg = {
|
|
10542
10378
|
kind: "init",
|
|
10543
10379
|
data: {
|
|
@@ -10577,11 +10413,11 @@ var E2EEManager = class extends eventsExports.EventEmitter {
|
|
|
10577
10413
|
this.postRTPMap(rtpMap);
|
|
10578
10414
|
});
|
|
10579
10415
|
}
|
|
10580
|
-
setupEventListeners(
|
|
10581
|
-
|
|
10582
|
-
|
|
10416
|
+
setupEventListeners(room2, keyProvider) {
|
|
10417
|
+
room2.on(RoomEvent.TrackPublished, (pub, participant) => this.setParticipantCryptorEnabled(pub.trackInfo.encryption !== Encryption_Type.NONE, participant.identity));
|
|
10418
|
+
room2.on(RoomEvent.ConnectionStateChanged, (state) => {
|
|
10583
10419
|
if (state === ConnectionState.Connected) {
|
|
10584
|
-
|
|
10420
|
+
room2.remoteParticipants.forEach((participant) => {
|
|
10585
10421
|
participant.trackPublications.forEach((pub) => {
|
|
10586
10422
|
this.setParticipantCryptorEnabled(pub.trackInfo.encryption !== Encryption_Type.NONE, participant.identity);
|
|
10587
10423
|
});
|
|
@@ -10608,7 +10444,7 @@ var E2EEManager = class extends eventsExports.EventEmitter {
|
|
|
10608
10444
|
});
|
|
10609
10445
|
this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled, this.room.localParticipant.identity);
|
|
10610
10446
|
});
|
|
10611
|
-
|
|
10447
|
+
room2.localParticipant.on(ParticipantEvent.LocalSenderCreated, (sender, track) => __awaiter(this, void 0, void 0, function* () {
|
|
10612
10448
|
this.setupE2EESender(track, sender);
|
|
10613
10449
|
}));
|
|
10614
10450
|
keyProvider.on(KeyProviderEvent.SetKey, (keyInfo) => this.postKey(keyInfo)).on(KeyProviderEvent.RatchetRequest, (participantId, keyIndex) => this.postRatchetRequest(participantId, keyIndex));
|
|
@@ -11017,15 +10853,15 @@ var SignalClient = class {
|
|
|
11017
10853
|
var _a, _b;
|
|
11018
10854
|
return (_b = (_a = this.loggerContextCb) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : {};
|
|
11019
10855
|
}
|
|
11020
|
-
join(url,
|
|
10856
|
+
join(url, token2, opts, abortSignal) {
|
|
11021
10857
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11022
10858
|
this.state = SignalConnectionState.CONNECTING;
|
|
11023
10859
|
this.options = opts;
|
|
11024
|
-
const res = yield this.connect(url,
|
|
10860
|
+
const res = yield this.connect(url, token2, opts, abortSignal);
|
|
11025
10861
|
return res;
|
|
11026
10862
|
});
|
|
11027
10863
|
}
|
|
11028
|
-
reconnect(url,
|
|
10864
|
+
reconnect(url, token2, sid, reason) {
|
|
11029
10865
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11030
10866
|
if (!this.options) {
|
|
11031
10867
|
this.log.warn("attempted to reconnect without signal options being set, ignoring", this.logContext);
|
|
@@ -11033,7 +10869,7 @@ var SignalClient = class {
|
|
|
11033
10869
|
}
|
|
11034
10870
|
this.state = SignalConnectionState.RECONNECTING;
|
|
11035
10871
|
this.clearPingInterval();
|
|
11036
|
-
const res = yield this.connect(url,
|
|
10872
|
+
const res = yield this.connect(url, token2, Object.assign(Object.assign({}, this.options), {
|
|
11037
10873
|
reconnect: true,
|
|
11038
10874
|
sid,
|
|
11039
10875
|
reconnectReason: reason
|
|
@@ -11041,10 +10877,10 @@ var SignalClient = class {
|
|
|
11041
10877
|
return res;
|
|
11042
10878
|
});
|
|
11043
10879
|
}
|
|
11044
|
-
connect(url,
|
|
10880
|
+
connect(url, token2, opts, abortSignal) {
|
|
11045
10881
|
this.connectOptions = opts;
|
|
11046
10882
|
const clientInfo = getClientInfo();
|
|
11047
|
-
const params = createConnectionParams(
|
|
10883
|
+
const params = createConnectionParams(token2, clientInfo, opts);
|
|
11048
10884
|
const rtcUrl = createRtcUrl(url, params);
|
|
11049
10885
|
const validateUrl = createValidateUrl(rtcUrl);
|
|
11050
10886
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -11586,10 +11422,10 @@ function toProtoSessionDescription(rsd, id) {
|
|
|
11586
11422
|
});
|
|
11587
11423
|
return sd;
|
|
11588
11424
|
}
|
|
11589
|
-
function createConnectionParams(
|
|
11425
|
+
function createConnectionParams(token2, info, opts) {
|
|
11590
11426
|
var _a;
|
|
11591
11427
|
const params = new URLSearchParams();
|
|
11592
|
-
params.set("access_token",
|
|
11428
|
+
params.set("access_token", token2);
|
|
11593
11429
|
if (opts.reconnect) {
|
|
11594
11430
|
params.set("reconnect", "1");
|
|
11595
11431
|
if (opts.sid) {
|
|
@@ -15445,16 +15281,16 @@ var RTCEngine = class extends eventsExports.EventEmitter {
|
|
|
15445
15281
|
pID: this.participantSid
|
|
15446
15282
|
};
|
|
15447
15283
|
}
|
|
15448
|
-
join(url,
|
|
15284
|
+
join(url, token2, opts, abortSignal) {
|
|
15449
15285
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15450
15286
|
this.url = url;
|
|
15451
|
-
this.token =
|
|
15287
|
+
this.token = token2;
|
|
15452
15288
|
this.signalOpts = opts;
|
|
15453
15289
|
this.maxJoinAttempts = opts.maxRetries;
|
|
15454
15290
|
try {
|
|
15455
15291
|
this.joinAttempts += 1;
|
|
15456
15292
|
this.setupSignalClientCallbacks();
|
|
15457
|
-
const joinResponse = yield this.client.join(url,
|
|
15293
|
+
const joinResponse = yield this.client.join(url, token2, opts, abortSignal);
|
|
15458
15294
|
this._isClosed = false;
|
|
15459
15295
|
this.latestJoinResponse = joinResponse;
|
|
15460
15296
|
this.subscriberPrimary = joinResponse.subscriberPrimary;
|
|
@@ -15472,7 +15308,7 @@ var RTCEngine = class extends eventsExports.EventEmitter {
|
|
|
15472
15308
|
if (e2.reason === ConnectionErrorReason.ServerUnreachable) {
|
|
15473
15309
|
this.log.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts, " of ").concat(this.maxJoinAttempts), this.logContext);
|
|
15474
15310
|
if (this.joinAttempts < this.maxJoinAttempts) {
|
|
15475
|
-
return this.join(url,
|
|
15311
|
+
return this.join(url, token2, opts, abortSignal);
|
|
15476
15312
|
}
|
|
15477
15313
|
}
|
|
15478
15314
|
}
|
|
@@ -15702,8 +15538,8 @@ var RTCEngine = class extends eventsExports.EventEmitter {
|
|
|
15702
15538
|
this.client.onLocalTrackSubscribed = (trackSid) => {
|
|
15703
15539
|
this.emit(EngineEvent.LocalTrackSubscribed, trackSid);
|
|
15704
15540
|
};
|
|
15705
|
-
this.client.onTokenRefresh = (
|
|
15706
|
-
this.token =
|
|
15541
|
+
this.client.onTokenRefresh = (token2) => {
|
|
15542
|
+
this.token = token2;
|
|
15707
15543
|
};
|
|
15708
15544
|
this.client.onRemoteMuteChanged = (trackSid, muted) => {
|
|
15709
15545
|
this.emit(EngineEvent.RemoteMute, trackSid, muted);
|
|
@@ -16390,15 +16226,15 @@ function applyUserDataCompat(newObj, oldObj) {
|
|
|
16390
16226
|
oldObj.destinationIdentities = destinationIdentities;
|
|
16391
16227
|
}
|
|
16392
16228
|
var RegionUrlProvider = class {
|
|
16393
|
-
constructor(url,
|
|
16229
|
+
constructor(url, token2) {
|
|
16394
16230
|
this.lastUpdateAt = 0;
|
|
16395
16231
|
this.settingsCacheTime = 3e3;
|
|
16396
16232
|
this.attemptedRegions = [];
|
|
16397
16233
|
this.serverUrl = new URL(url);
|
|
16398
|
-
this.token =
|
|
16234
|
+
this.token = token2;
|
|
16399
16235
|
}
|
|
16400
|
-
updateToken(
|
|
16401
|
-
this.token =
|
|
16236
|
+
updateToken(token2) {
|
|
16237
|
+
this.token = token2;
|
|
16402
16238
|
}
|
|
16403
16239
|
isCloud() {
|
|
16404
16240
|
return isCloud(this.serverUrl);
|
|
@@ -16451,8 +16287,8 @@ var RegionUrlProvider = class {
|
|
|
16451
16287
|
this.lastUpdateAt = Date.now();
|
|
16452
16288
|
}
|
|
16453
16289
|
};
|
|
16454
|
-
function getCloudConfigUrl(
|
|
16455
|
-
return "".concat(
|
|
16290
|
+
function getCloudConfigUrl(serverUrl2) {
|
|
16291
|
+
return "".concat(serverUrl2.protocol.replace("ws", "http"), "//").concat(serverUrl2.host, "/settings");
|
|
16456
16292
|
}
|
|
16457
16293
|
var BaseStreamReader = class {
|
|
16458
16294
|
get info() {
|
|
@@ -17615,34 +17451,6 @@ function createLocalAudioTrack(options) {
|
|
|
17615
17451
|
return tracks[0];
|
|
17616
17452
|
});
|
|
17617
17453
|
}
|
|
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
|
-
}
|
|
17646
17454
|
var ConnectionQuality;
|
|
17647
17455
|
(function(ConnectionQuality2) {
|
|
17648
17456
|
ConnectionQuality2["Excellent"] = "excellent";
|
|
@@ -20319,7 +20127,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20319
20127
|
this.byteStreamHandlers = /* @__PURE__ */ new Map();
|
|
20320
20128
|
this.textStreamHandlers = /* @__PURE__ */ new Map();
|
|
20321
20129
|
this.rpcHandlers = /* @__PURE__ */ new Map();
|
|
20322
|
-
this.connect = (url,
|
|
20130
|
+
this.connect = (url, token2, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
20323
20131
|
var _a2;
|
|
20324
20132
|
if (!isBrowserSupported()) {
|
|
20325
20133
|
if (isReactNative()) {
|
|
@@ -20345,9 +20153,9 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20345
20153
|
}
|
|
20346
20154
|
if (isCloud(new URL(url))) {
|
|
20347
20155
|
if (this.regionUrlProvider === void 0) {
|
|
20348
|
-
this.regionUrlProvider = new RegionUrlProvider(url,
|
|
20156
|
+
this.regionUrlProvider = new RegionUrlProvider(url, token2);
|
|
20349
20157
|
} else {
|
|
20350
|
-
this.regionUrlProvider.updateToken(
|
|
20158
|
+
this.regionUrlProvider.updateToken(token2);
|
|
20351
20159
|
}
|
|
20352
20160
|
this.regionUrlProvider.fetchRegionSettings().then((settings) => {
|
|
20353
20161
|
var _a3;
|
|
@@ -20367,7 +20175,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20367
20175
|
this.abortController = abortController;
|
|
20368
20176
|
unlockDisconnect === null || unlockDisconnect === void 0 ? void 0 : unlockDisconnect();
|
|
20369
20177
|
try {
|
|
20370
|
-
yield this.attemptConnection(regionUrl2 !== null && regionUrl2 !== void 0 ? regionUrl2 : url,
|
|
20178
|
+
yield this.attemptConnection(regionUrl2 !== null && regionUrl2 !== void 0 ? regionUrl2 : url, token2, opts, abortController);
|
|
20371
20179
|
this.abortController = void 0;
|
|
20372
20180
|
resolve();
|
|
20373
20181
|
} catch (e2) {
|
|
@@ -20409,9 +20217,9 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20409
20217
|
});
|
|
20410
20218
|
return this.connectFuture.promise;
|
|
20411
20219
|
});
|
|
20412
|
-
this.connectSignal = (url,
|
|
20220
|
+
this.connectSignal = (url, token2, engine, connectOptions, roomOptions, abortController) => __awaiter(this, void 0, void 0, function* () {
|
|
20413
20221
|
var _a2, _b2, _c2;
|
|
20414
|
-
const joinResponse = yield engine.join(url,
|
|
20222
|
+
const joinResponse = yield engine.join(url, token2, {
|
|
20415
20223
|
autoSubscribe: connectOptions.autoSubscribe,
|
|
20416
20224
|
adaptiveStream: typeof roomOptions.adaptiveStream === "object" ? true : roomOptions.adaptiveStream,
|
|
20417
20225
|
maxRetries: connectOptions.maxRetries,
|
|
@@ -20462,7 +20270,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20462
20270
|
this.handleRoomUpdate(joinResponse.room);
|
|
20463
20271
|
}
|
|
20464
20272
|
};
|
|
20465
|
-
this.attemptConnection = (url,
|
|
20273
|
+
this.attemptConnection = (url, token2, opts, abortController) => __awaiter(this, void 0, void 0, function* () {
|
|
20466
20274
|
var _a2, _b2;
|
|
20467
20275
|
if (this.state === ConnectionState.Reconnecting || this.isResuming || ((_a2 = this.engine) === null || _a2 === void 0 ? void 0 : _a2.pendingReconnect)) {
|
|
20468
20276
|
this.log.info("Reconnection attempt replaced by new connection attempt", this.logContext);
|
|
@@ -20482,7 +20290,7 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20482
20290
|
this.engine.peerConnectionTimeout = this.connOptions.peerConnectionTimeout;
|
|
20483
20291
|
}
|
|
20484
20292
|
try {
|
|
20485
|
-
const joinResponse = yield this.connectSignal(url,
|
|
20293
|
+
const joinResponse = yield this.connectSignal(url, token2, this.engine, this.connOptions, this.options, abortController);
|
|
20486
20294
|
this.applyJoinResponse(joinResponse);
|
|
20487
20295
|
this.setupLocalParticipantEvents();
|
|
20488
20296
|
this.emit(RoomEvent.SignalConnected);
|
|
@@ -20878,14 +20686,14 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
20878
20686
|
}
|
|
20879
20687
|
this.emit(RoomEvent.MediaDevicesChanged);
|
|
20880
20688
|
});
|
|
20881
|
-
this.handleRoomUpdate = (
|
|
20689
|
+
this.handleRoomUpdate = (room2) => {
|
|
20882
20690
|
const oldRoom = this.roomInfo;
|
|
20883
|
-
this.roomInfo =
|
|
20884
|
-
if (oldRoom && oldRoom.metadata !==
|
|
20885
|
-
this.emitWhenConnected(RoomEvent.RoomMetadataChanged,
|
|
20691
|
+
this.roomInfo = room2;
|
|
20692
|
+
if (oldRoom && oldRoom.metadata !== room2.metadata) {
|
|
20693
|
+
this.emitWhenConnected(RoomEvent.RoomMetadataChanged, room2.metadata);
|
|
20886
20694
|
}
|
|
20887
|
-
if ((oldRoom === null || oldRoom === void 0 ? void 0 : oldRoom.activeRecording) !==
|
|
20888
|
-
this.emitWhenConnected(RoomEvent.RecordingStatusChanged,
|
|
20695
|
+
if ((oldRoom === null || oldRoom === void 0 ? void 0 : oldRoom.activeRecording) !== room2.activeRecording) {
|
|
20696
|
+
this.emitWhenConnected(RoomEvent.RecordingStatusChanged, room2.activeRecording);
|
|
20889
20697
|
}
|
|
20890
20698
|
};
|
|
20891
20699
|
this.handleConnectionQualityUpdate = (update) => {
|
|
@@ -21282,15 +21090,15 @@ var Room = class _Room extends eventsExports.EventEmitter {
|
|
|
21282
21090
|
* With LiveKit Cloud, it will also determine the best edge data center for
|
|
21283
21091
|
* the current client to connect to if a token is provided.
|
|
21284
21092
|
*/
|
|
21285
|
-
prepareConnection(url,
|
|
21093
|
+
prepareConnection(url, token2) {
|
|
21286
21094
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21287
21095
|
if (this.state !== ConnectionState.Disconnected) {
|
|
21288
21096
|
return;
|
|
21289
21097
|
}
|
|
21290
21098
|
this.log.debug("prepareConnection to ".concat(url), this.logContext);
|
|
21291
21099
|
try {
|
|
21292
|
-
if (isCloud(new URL(url)) &&
|
|
21293
|
-
this.regionUrlProvider = new RegionUrlProvider(url,
|
|
21100
|
+
if (isCloud(new URL(url)) && token2) {
|
|
21101
|
+
this.regionUrlProvider = new RegionUrlProvider(url, token2);
|
|
21294
21102
|
const regionUrl = yield this.regionUrlProvider.getNextBestRegionUrl();
|
|
21295
21103
|
if (regionUrl && this.state === ConnectionState.Disconnected) {
|
|
21296
21104
|
this.regionUrl = regionUrl;
|
|
@@ -22148,24 +21956,6 @@ function mapArgs(args) {
|
|
|
22148
21956
|
return arg;
|
|
22149
21957
|
});
|
|
22150
21958
|
}
|
|
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
|
-
});
|
|
22169
21959
|
var CheckStatus;
|
|
22170
21960
|
(function(CheckStatus2) {
|
|
22171
21961
|
CheckStatus2[CheckStatus2["IDLE"] = 0] = "IDLE";
|
|
@@ -22175,14 +21965,14 @@ var CheckStatus;
|
|
|
22175
21965
|
CheckStatus2[CheckStatus2["FAILED"] = 4] = "FAILED";
|
|
22176
21966
|
})(CheckStatus || (CheckStatus = {}));
|
|
22177
21967
|
var Checker = class extends eventsExports.EventEmitter {
|
|
22178
|
-
constructor(url,
|
|
21968
|
+
constructor(url, token2) {
|
|
22179
21969
|
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
22180
21970
|
super();
|
|
22181
21971
|
this.status = CheckStatus.IDLE;
|
|
22182
21972
|
this.logs = [];
|
|
22183
21973
|
this.options = {};
|
|
22184
21974
|
this.url = url;
|
|
22185
|
-
this.token =
|
|
21975
|
+
this.token = token2;
|
|
22186
21976
|
this.name = this.constructor.name;
|
|
22187
21977
|
this.room = new Room(options.roomOptions);
|
|
22188
21978
|
this.connectOptions = options.connectOptions;
|
|
@@ -22494,14 +22284,14 @@ var PublishAudioCheck = class extends Checker {
|
|
|
22494
22284
|
perform() {
|
|
22495
22285
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22496
22286
|
var _a;
|
|
22497
|
-
const
|
|
22287
|
+
const room2 = yield this.connect();
|
|
22498
22288
|
const track = yield createLocalAudioTrack();
|
|
22499
22289
|
const trackIsSilent = yield detectSilence(track, 1e3);
|
|
22500
22290
|
if (trackIsSilent) {
|
|
22501
22291
|
throw new Error("unable to detect audio from microphone");
|
|
22502
22292
|
}
|
|
22503
22293
|
this.appendMessage("detected audio from microphone");
|
|
22504
|
-
|
|
22294
|
+
room2.localParticipant.publishTrack(track);
|
|
22505
22295
|
yield new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
22506
22296
|
const stats = yield (_a = track.sender) === null || _a === void 0 ? void 0 : _a.getStats();
|
|
22507
22297
|
if (!stats) {
|
|
@@ -22527,10 +22317,10 @@ var PublishVideoCheck = class extends Checker {
|
|
|
22527
22317
|
perform() {
|
|
22528
22318
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22529
22319
|
var _a;
|
|
22530
|
-
const
|
|
22320
|
+
const room2 = yield this.connect();
|
|
22531
22321
|
const track = yield createLocalVideoTrack();
|
|
22532
22322
|
yield this.checkForVideo(track.mediaStreamTrack);
|
|
22533
|
-
|
|
22323
|
+
room2.localParticipant.publishTrack(track);
|
|
22534
22324
|
yield new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
22535
22325
|
const stats = yield (_a = track.sender) === null || _a === void 0 ? void 0 : _a.getStats();
|
|
22536
22326
|
if (!stats) {
|
|
@@ -22598,30 +22388,30 @@ var ReconnectCheck = class extends Checker {
|
|
|
22598
22388
|
perform() {
|
|
22599
22389
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22600
22390
|
var _a;
|
|
22601
|
-
const
|
|
22391
|
+
const room2 = yield this.connect();
|
|
22602
22392
|
let reconnectingTriggered = false;
|
|
22603
22393
|
let reconnected = false;
|
|
22604
22394
|
let reconnectResolver;
|
|
22605
|
-
const
|
|
22395
|
+
const reconnectTimeout2 = new Promise((resolve) => {
|
|
22606
22396
|
setTimeout(resolve, 5e3);
|
|
22607
22397
|
reconnectResolver = resolve;
|
|
22608
22398
|
});
|
|
22609
22399
|
const handleReconnecting = () => {
|
|
22610
22400
|
reconnectingTriggered = true;
|
|
22611
22401
|
};
|
|
22612
|
-
|
|
22402
|
+
room2.on(RoomEvent.SignalReconnecting, handleReconnecting).on(RoomEvent.Reconnecting, handleReconnecting).on(RoomEvent.Reconnected, () => {
|
|
22613
22403
|
reconnected = true;
|
|
22614
22404
|
reconnectResolver(true);
|
|
22615
22405
|
});
|
|
22616
|
-
(_a =
|
|
22617
|
-
const onClose =
|
|
22406
|
+
(_a = room2.engine.client.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
22407
|
+
const onClose = room2.engine.client.onClose;
|
|
22618
22408
|
if (onClose) {
|
|
22619
22409
|
onClose("");
|
|
22620
22410
|
}
|
|
22621
|
-
yield
|
|
22411
|
+
yield reconnectTimeout2;
|
|
22622
22412
|
if (!reconnectingTriggered) {
|
|
22623
22413
|
throw new Error("Did not attempt to reconnect");
|
|
22624
|
-
} else if (!reconnected ||
|
|
22414
|
+
} else if (!reconnected || room2.state !== ConnectionState.Connected) {
|
|
22625
22415
|
this.appendWarning("reconnection is only possible in Redis-based configurations");
|
|
22626
22416
|
throw new Error("Not able to reconnect");
|
|
22627
22417
|
}
|
|
@@ -22778,13 +22568,13 @@ var WebSocketCheck = class extends Checker {
|
|
|
22778
22568
|
}
|
|
22779
22569
|
};
|
|
22780
22570
|
var ConnectionCheck = class extends eventsExports.EventEmitter {
|
|
22781
|
-
constructor(url,
|
|
22571
|
+
constructor(url, token2) {
|
|
22782
22572
|
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
22783
22573
|
super();
|
|
22784
22574
|
this.options = {};
|
|
22785
22575
|
this.checkResults = /* @__PURE__ */ new Map();
|
|
22786
22576
|
this.url = url;
|
|
22787
|
-
this.token =
|
|
22577
|
+
this.token = token2;
|
|
22788
22578
|
this.options = options;
|
|
22789
22579
|
}
|
|
22790
22580
|
getNextCheckId() {
|
|
@@ -22866,172 +22656,722 @@ var ConnectionCheck = class extends eventsExports.EventEmitter {
|
|
|
22866
22656
|
});
|
|
22867
22657
|
}
|
|
22868
22658
|
};
|
|
22869
|
-
|
|
22870
|
-
|
|
22871
|
-
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
|
|
22878
|
-
|
|
22879
|
-
|
|
22880
|
-
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
22886
|
-
|
|
22887
|
-
|
|
22659
|
+
|
|
22660
|
+
// src/core/globals.ts
|
|
22661
|
+
var _apiKey = "";
|
|
22662
|
+
var _appId = "";
|
|
22663
|
+
var setApiKey = (key) => _apiKey = key;
|
|
22664
|
+
var setAppId = (id) => _appId = id;
|
|
22665
|
+
var _webRTCConfig = null;
|
|
22666
|
+
var _webRTCConnectionState = {
|
|
22667
|
+
isConnected: false,
|
|
22668
|
+
isConnecting: false,
|
|
22669
|
+
participants: []
|
|
22670
|
+
};
|
|
22671
|
+
var setWebRTCConfig = (config) => _webRTCConfig = config;
|
|
22672
|
+
var setWebRTCConnectionState = (state) => {
|
|
22673
|
+
_webRTCConnectionState = { ..._webRTCConnectionState, ...state };
|
|
22674
|
+
};
|
|
22675
|
+
|
|
22676
|
+
// src/constants/index.ts
|
|
22677
|
+
var WEBRTC_BACKEND_SERVER_URL = "https://api-webrtc-dev.ansyr.ai";
|
|
22678
|
+
|
|
22679
|
+
// src/core/intent-store.ts
|
|
22680
|
+
var store = {
|
|
22681
|
+
screenMetadata: {},
|
|
22682
|
+
allElementsData: []
|
|
22683
|
+
};
|
|
22684
|
+
var GlobalStore = {
|
|
22685
|
+
// 🔹 Screen Metadata Methods
|
|
22686
|
+
setMetadata(screen, metadata) {
|
|
22687
|
+
store.screenMetadata[screen] = metadata;
|
|
22688
|
+
},
|
|
22689
|
+
getMetadata(screen) {
|
|
22690
|
+
return store.screenMetadata[screen];
|
|
22691
|
+
},
|
|
22692
|
+
clearMetadata(screen) {
|
|
22693
|
+
delete store.screenMetadata[screen];
|
|
22694
|
+
},
|
|
22695
|
+
// 🔹 Generic Store Access Methods
|
|
22696
|
+
setData(key, value) {
|
|
22697
|
+
store[key] = value;
|
|
22698
|
+
},
|
|
22699
|
+
getData(key) {
|
|
22700
|
+
return store[key];
|
|
22701
|
+
},
|
|
22702
|
+
clearData(key) {
|
|
22703
|
+
delete store[key];
|
|
22704
|
+
},
|
|
22705
|
+
// 🔹 Element Data Management
|
|
22706
|
+
setElement(elementData) {
|
|
22707
|
+
const index = store.allElementsData.findIndex((e2) => e2.elementId === elementData.elementId);
|
|
22708
|
+
if (index >= 0) {
|
|
22709
|
+
store.allElementsData[index] = elementData;
|
|
22710
|
+
} else {
|
|
22711
|
+
store.allElementsData.push(elementData);
|
|
22712
|
+
}
|
|
22713
|
+
},
|
|
22714
|
+
getElementById(elementId) {
|
|
22715
|
+
const match = store.allElementsData.find((e2) => e2.elementId === elementId);
|
|
22716
|
+
if (!match) {
|
|
22888
22717
|
}
|
|
22718
|
+
return match;
|
|
22719
|
+
},
|
|
22720
|
+
deleteElementById(id) {
|
|
22721
|
+
store.allElementsData = store.allElementsData.filter((e2) => e2.elementId !== id);
|
|
22722
|
+
},
|
|
22723
|
+
clearAllElements() {
|
|
22724
|
+
store.allElementsData = [];
|
|
22889
22725
|
}
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
|
|
22893
|
-
|
|
22894
|
-
|
|
22726
|
+
};
|
|
22727
|
+
|
|
22728
|
+
// src/core/navigation.ts
|
|
22729
|
+
var navigation;
|
|
22730
|
+
var navigationHandler = null;
|
|
22731
|
+
function setNavigationHandler(handler) {
|
|
22732
|
+
navigationHandler = handler;
|
|
22733
|
+
}
|
|
22734
|
+
function navigate(path, params) {
|
|
22735
|
+
const safeParams = params || {};
|
|
22736
|
+
const absolutePath = path.startsWith("/") ? path : `/${path}`;
|
|
22737
|
+
if (navigationHandler) {
|
|
22738
|
+
try {
|
|
22739
|
+
navigationHandler(absolutePath, safeParams);
|
|
22740
|
+
} catch (error) {
|
|
22741
|
+
}
|
|
22742
|
+
return;
|
|
22743
|
+
}
|
|
22744
|
+
let fullPath = absolutePath;
|
|
22745
|
+
if (safeParams) {
|
|
22746
|
+
const searchParams = new URLSearchParams(safeParams).toString();
|
|
22747
|
+
if (searchParams) {
|
|
22748
|
+
fullPath += `?${searchParams}`;
|
|
22749
|
+
}
|
|
22750
|
+
}
|
|
22751
|
+
if (navigation) {
|
|
22752
|
+
navigation.push(fullPath);
|
|
22753
|
+
} else {
|
|
22754
|
+
if (typeof window !== "undefined") {
|
|
22755
|
+
window.location.href = fullPath;
|
|
22895
22756
|
}
|
|
22896
22757
|
}
|
|
22758
|
+
}
|
|
22759
|
+
var getCurrentPath = () => {
|
|
22760
|
+
if (typeof window === "undefined") return "";
|
|
22761
|
+
return window.location.pathname;
|
|
22762
|
+
};
|
|
22763
|
+
var getSearchParams = () => {
|
|
22764
|
+
if (typeof window === "undefined") return new URLSearchParams();
|
|
22765
|
+
return new URLSearchParams(window.location.search);
|
|
22766
|
+
};
|
|
22767
|
+
var safeNavigate = (name, params = {}) => {
|
|
22768
|
+
if (name) {
|
|
22769
|
+
navigate(name, params);
|
|
22770
|
+
} else {
|
|
22771
|
+
}
|
|
22772
|
+
};
|
|
22773
|
+
function getCurrentScreenName() {
|
|
22774
|
+
try {
|
|
22775
|
+
const path = getCurrentPath();
|
|
22776
|
+
return path || "UnknownScreen";
|
|
22777
|
+
} catch (e2) {
|
|
22778
|
+
return "UnknownScreen";
|
|
22779
|
+
}
|
|
22780
|
+
}
|
|
22781
|
+
function getCurrentRouteParams() {
|
|
22782
|
+
try {
|
|
22783
|
+
const params = {};
|
|
22784
|
+
const searchParams = getSearchParams();
|
|
22785
|
+
if (searchParams instanceof URLSearchParams) {
|
|
22786
|
+
searchParams.forEach((value, key) => {
|
|
22787
|
+
params[key] = value;
|
|
22788
|
+
});
|
|
22789
|
+
} else {
|
|
22790
|
+
return searchParams;
|
|
22791
|
+
}
|
|
22792
|
+
return params;
|
|
22793
|
+
} catch (e2) {
|
|
22794
|
+
return {};
|
|
22795
|
+
}
|
|
22796
|
+
}
|
|
22797
|
+
function onStateChange() {
|
|
22798
|
+
const routeName = getCurrentScreenName();
|
|
22799
|
+
const params = getCurrentRouteParams();
|
|
22800
|
+
if (params && params.metadata) {
|
|
22801
|
+
try {
|
|
22802
|
+
const metadata = JSON.parse(params.metadata);
|
|
22803
|
+
GlobalStore.setMetadata(routeName, metadata);
|
|
22804
|
+
} catch (error) {
|
|
22805
|
+
}
|
|
22806
|
+
}
|
|
22807
|
+
}
|
|
22808
|
+
var handleNavigationAndClick = (routeName, elementHash) => {
|
|
22809
|
+
safeNavigate(routeName);
|
|
22810
|
+
if (typeof MutationObserver === "undefined" || typeof document === "undefined") return;
|
|
22811
|
+
const observer = new MutationObserver((mutationsList, observer2) => {
|
|
22812
|
+
setTimeout(() => {
|
|
22813
|
+
const allElements = document.querySelectorAll("*");
|
|
22814
|
+
let elementToClick = null;
|
|
22815
|
+
for (const element of allElements) {
|
|
22816
|
+
if (element instanceof HTMLElement) {
|
|
22817
|
+
const tagName = element.tagName.toLowerCase();
|
|
22818
|
+
const text = (element.textContent || "").trim().substring(0, 50);
|
|
22819
|
+
let sibling = element.previousElementSibling;
|
|
22820
|
+
let position = 1;
|
|
22821
|
+
while (sibling) {
|
|
22822
|
+
if (sibling.tagName === element.tagName) {
|
|
22823
|
+
position++;
|
|
22824
|
+
}
|
|
22825
|
+
sibling = sibling.previousElementSibling;
|
|
22826
|
+
}
|
|
22827
|
+
const path = getElementPath(element);
|
|
22828
|
+
const idString = `${tagName}[${position}]_(${text})_${path}`;
|
|
22829
|
+
let hash = 0;
|
|
22830
|
+
for (let i = 0; i < idString.length; i++) {
|
|
22831
|
+
const char = idString.charCodeAt(i);
|
|
22832
|
+
hash = (hash << 5) - hash + char;
|
|
22833
|
+
hash |= 0;
|
|
22834
|
+
}
|
|
22835
|
+
const elementHashValue = hash.toString(36);
|
|
22836
|
+
if (elementHashValue === elementHash) {
|
|
22837
|
+
elementToClick = element;
|
|
22838
|
+
break;
|
|
22839
|
+
}
|
|
22840
|
+
}
|
|
22841
|
+
}
|
|
22842
|
+
if (elementToClick) {
|
|
22843
|
+
elementToClick.click();
|
|
22844
|
+
observer2.disconnect();
|
|
22845
|
+
}
|
|
22846
|
+
}, 100);
|
|
22847
|
+
});
|
|
22848
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
22849
|
+
};
|
|
22850
|
+
function getElementPath(element) {
|
|
22851
|
+
if (element.id) {
|
|
22852
|
+
return `id(${element.id})`;
|
|
22853
|
+
}
|
|
22854
|
+
const path = [];
|
|
22855
|
+
let current = element;
|
|
22856
|
+
while (current && current !== document.body) {
|
|
22857
|
+
let index = 1;
|
|
22858
|
+
let sibling = current.previousElementSibling;
|
|
22859
|
+
while (sibling) {
|
|
22860
|
+
if (sibling.tagName === current.tagName) {
|
|
22861
|
+
index++;
|
|
22862
|
+
}
|
|
22863
|
+
sibling = sibling.previousElementSibling;
|
|
22864
|
+
}
|
|
22865
|
+
path.unshift(`${current.tagName.toLowerCase()}[${index}]`);
|
|
22866
|
+
current = current.parentElement;
|
|
22867
|
+
}
|
|
22868
|
+
return path.join("/");
|
|
22869
|
+
}
|
|
22870
|
+
|
|
22871
|
+
// src/utils/jsx-encoder.ts
|
|
22872
|
+
function generateStableDOMId(element) {
|
|
22873
|
+
const tagName = element.tagName.toLowerCase();
|
|
22874
|
+
const text = (element.textContent || "").trim().substring(0, 50);
|
|
22875
|
+
let sibling = element.previousElementSibling;
|
|
22876
|
+
let position = 1;
|
|
22877
|
+
while (sibling) {
|
|
22878
|
+
if (sibling.tagName === element.tagName) {
|
|
22879
|
+
position++;
|
|
22880
|
+
}
|
|
22881
|
+
sibling = sibling.previousElementSibling;
|
|
22882
|
+
}
|
|
22883
|
+
const path = getElementPath2(element);
|
|
22884
|
+
const idString = `${tagName}[${position}]_(${text})_${path}`;
|
|
22885
|
+
let hash = 0;
|
|
22886
|
+
for (let i = 0; i < idString.length; i++) {
|
|
22887
|
+
const char = idString.charCodeAt(i);
|
|
22888
|
+
hash = (hash << 5) - hash + char;
|
|
22889
|
+
hash |= 0;
|
|
22890
|
+
}
|
|
22891
|
+
return hash.toString(36);
|
|
22892
|
+
}
|
|
22893
|
+
function getElementPath2(element) {
|
|
22894
|
+
if (element.id) {
|
|
22895
|
+
return `id(${element.id})`;
|
|
22896
|
+
}
|
|
22897
|
+
if (element.tagName.toLowerCase() === "body") {
|
|
22898
|
+
return "/body";
|
|
22899
|
+
}
|
|
22900
|
+
let ix = 0;
|
|
22901
|
+
const siblings = element.parentNode?.children || new HTMLCollection();
|
|
22902
|
+
for (let i = 0; i < siblings.length; i++) {
|
|
22903
|
+
const sibling = siblings[i];
|
|
22904
|
+
if (sibling === element) {
|
|
22905
|
+
return `${getElementPath2(element.parentNode)}/${element.tagName}[${ix + 1}]`;
|
|
22906
|
+
}
|
|
22907
|
+
if (sibling.nodeType === 1 && sibling.tagName === element.tagName) {
|
|
22908
|
+
ix++;
|
|
22909
|
+
}
|
|
22910
|
+
}
|
|
22911
|
+
return "not_found";
|
|
22912
|
+
}
|
|
22913
|
+
|
|
22914
|
+
// src/utils/element-service.ts
|
|
22915
|
+
var INTERACTIVE_ELEMENT_SELECTOR = 'a, button, input, textarea, select, [role="button"], [onclick], [data-ansyr-static], [data-ansyr-dynamic]';
|
|
22916
|
+
function getInteractiveElements() {
|
|
22917
|
+
const elements = document.querySelectorAll(INTERACTIVE_ELEMENT_SELECTOR);
|
|
22918
|
+
return Array.from(new Set(Array.from(elements)));
|
|
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 for Cuekit...");
|
|
22933
|
+
const interactiveElements = [];
|
|
22934
|
+
const descriptionsMap = /* @__PURE__ */ new Map();
|
|
22935
|
+
document.querySelectorAll("[data-for]").forEach((el) => {
|
|
22936
|
+
const targetId = el.getAttribute("data-for");
|
|
22937
|
+
if (!targetId) return;
|
|
22938
|
+
const tags = [];
|
|
22939
|
+
const description = el.getAttribute("data-ansyr-description");
|
|
22940
|
+
if (description) {
|
|
22941
|
+
tags.push(description);
|
|
22942
|
+
}
|
|
22943
|
+
if (el.textContent) {
|
|
22944
|
+
tags.push(el.textContent.trim());
|
|
22945
|
+
}
|
|
22946
|
+
if (tags.length > 0) {
|
|
22947
|
+
const existingTags = descriptionsMap.get(targetId) || [];
|
|
22948
|
+
descriptionsMap.set(targetId, [...existingTags, ...tags]);
|
|
22949
|
+
}
|
|
22950
|
+
});
|
|
22951
|
+
const allElements = getInteractiveElements();
|
|
22952
|
+
allElements.forEach((element) => {
|
|
22953
|
+
const style = getComputedStyle(element);
|
|
22954
|
+
if (element.closest("[data-cuekit-ignore]") || !isElementClickable(element) || element.tagName.toLowerCase() === "script" || style.display === "none" || style.visibility === "hidden") {
|
|
22955
|
+
return;
|
|
22956
|
+
}
|
|
22957
|
+
const staticId = element.getAttribute("data-ansyr-static");
|
|
22958
|
+
const dynamicId = element.getAttribute("data-ansyr-dynamic");
|
|
22959
|
+
const id = staticId || dynamicId;
|
|
22960
|
+
const tags = [];
|
|
22961
|
+
const directDescription = element.getAttribute("data-ansyr-description");
|
|
22962
|
+
if (directDescription) {
|
|
22963
|
+
tags.push(directDescription);
|
|
22964
|
+
}
|
|
22965
|
+
if (id && descriptionsMap.has(id)) {
|
|
22966
|
+
tags.push(...descriptionsMap.get(id) || []);
|
|
22967
|
+
}
|
|
22968
|
+
const dto = {
|
|
22969
|
+
testID: id || generateStableDOMId(element),
|
|
22970
|
+
type: element.tagName.toLowerCase(),
|
|
22971
|
+
textContent: getImmediateText(element) || element.textContent?.trim() || "",
|
|
22972
|
+
tags
|
|
22973
|
+
};
|
|
22974
|
+
interactiveElements.push(dto);
|
|
22975
|
+
});
|
|
22976
|
+
const result = {
|
|
22977
|
+
components: interactiveElements
|
|
22978
|
+
};
|
|
22979
|
+
console.log("\u{1F333} Full DOM structure captured:", result);
|
|
22897
22980
|
return result;
|
|
22898
22981
|
}
|
|
22899
|
-
|
|
22900
|
-
|
|
22901
|
-
|
|
22902
|
-
|
|
22903
|
-
|
|
22904
|
-
|
|
22905
|
-
|
|
22906
|
-
|
|
22907
|
-
|
|
22908
|
-
|
|
22909
|
-
|
|
22910
|
-
|
|
22911
|
-
|
|
22912
|
-
|
|
22913
|
-
|
|
22914
|
-
|
|
22982
|
+
function isElementClickable(element) {
|
|
22983
|
+
const interactiveSelectors = [
|
|
22984
|
+
"button",
|
|
22985
|
+
"a",
|
|
22986
|
+
"input",
|
|
22987
|
+
"select",
|
|
22988
|
+
"textarea",
|
|
22989
|
+
'[role="button"]',
|
|
22990
|
+
'[role="link"]',
|
|
22991
|
+
'[role="tab"]',
|
|
22992
|
+
"[data-onclick-id]",
|
|
22993
|
+
"[data-on-press-id]",
|
|
22994
|
+
"[onclick]",
|
|
22995
|
+
"[onmousedown]",
|
|
22996
|
+
"[onmouseup]",
|
|
22997
|
+
"[ontouchstart]",
|
|
22998
|
+
"[ontouchend]",
|
|
22999
|
+
"[onkeydown]",
|
|
23000
|
+
"[onkeyup]",
|
|
23001
|
+
"[onkeypress]"
|
|
23002
|
+
];
|
|
23003
|
+
for (const selector of interactiveSelectors) {
|
|
23004
|
+
if (element.matches(selector)) {
|
|
23005
|
+
return true;
|
|
23006
|
+
}
|
|
23007
|
+
}
|
|
23008
|
+
const hasClickEvents = element.onclick !== null || element.getAttribute("onclick") !== null;
|
|
23009
|
+
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;
|
|
23010
|
+
const hasPointerCursor = element.style.cursor === "pointer" || getComputedStyle(element).cursor === "pointer";
|
|
23011
|
+
const hasTabIndex = element.hasAttribute("tabindex") && parseInt(element.getAttribute("tabindex") || "0") >= 0;
|
|
23012
|
+
const hasInteractiveDataAttrs = element.hasAttribute("data-clickable") || element.hasAttribute("data-interactive") || element.hasAttribute("data-action") || element.hasAttribute("data-handler");
|
|
23013
|
+
const hasInteractiveAria = element.hasAttribute("aria-pressed") || element.hasAttribute("aria-expanded") || element.hasAttribute("aria-selected") || element.hasAttribute("aria-checked");
|
|
23014
|
+
return hasClickEvents || hasInteractiveEvents || hasPointerCursor || hasTabIndex || hasInteractiveDataAttrs || hasInteractiveAria;
|
|
23015
|
+
}
|
|
23016
|
+
function executeAction(action) {
|
|
23017
|
+
console.log("\u{1F3AF} Executing element action:", action);
|
|
23018
|
+
const { action_type, target_element, target } = action;
|
|
23019
|
+
switch (action_type) {
|
|
23020
|
+
case "click":
|
|
23021
|
+
return clickElement(target_element);
|
|
23022
|
+
case "navigate":
|
|
23023
|
+
return navigateToElement(target_element || target);
|
|
23024
|
+
case "input":
|
|
23025
|
+
case "focus":
|
|
23026
|
+
return focusElement(target_element);
|
|
23027
|
+
case "toggle":
|
|
23028
|
+
return toggleElement(target_element);
|
|
23029
|
+
default:
|
|
23030
|
+
console.warn(`\u26A0\uFE0F Unknown action type: ${action_type}`);
|
|
23031
|
+
return false;
|
|
23032
|
+
}
|
|
23033
|
+
}
|
|
23034
|
+
function getFullDOMStructure() {
|
|
23035
|
+
return captureFullDOMStructure();
|
|
23036
|
+
}
|
|
23037
|
+
function clickElement(elementId) {
|
|
23038
|
+
if (!elementId) {
|
|
23039
|
+
return false;
|
|
23040
|
+
}
|
|
23041
|
+
const domElement = findDOMElementById(elementId);
|
|
23042
|
+
if (domElement) {
|
|
23043
|
+
domElement.click();
|
|
23044
|
+
return true;
|
|
23045
|
+
}
|
|
23046
|
+
return false;
|
|
23047
|
+
}
|
|
23048
|
+
function navigateToElement(target) {
|
|
23049
|
+
if (!target) {
|
|
23050
|
+
return false;
|
|
23051
|
+
}
|
|
23052
|
+
if (target.includes("/") || target.startsWith("http")) {
|
|
23053
|
+
safeNavigate(target, {});
|
|
23054
|
+
} else {
|
|
23055
|
+
handleNavigationAndClick(target, target);
|
|
23056
|
+
}
|
|
23057
|
+
return true;
|
|
23058
|
+
}
|
|
23059
|
+
function focusElement(elementId) {
|
|
23060
|
+
if (!elementId) {
|
|
23061
|
+
return false;
|
|
23062
|
+
}
|
|
23063
|
+
const domElement = findDOMElementById(elementId);
|
|
23064
|
+
if (domElement instanceof HTMLInputElement || domElement instanceof HTMLTextAreaElement || domElement instanceof HTMLSelectElement) {
|
|
23065
|
+
domElement.focus();
|
|
23066
|
+
return true;
|
|
23067
|
+
} else {
|
|
23068
|
+
return false;
|
|
23069
|
+
}
|
|
23070
|
+
}
|
|
23071
|
+
function toggleElement(elementId) {
|
|
23072
|
+
if (!elementId) {
|
|
23073
|
+
return false;
|
|
23074
|
+
}
|
|
23075
|
+
const domElement = findDOMElementById(elementId);
|
|
23076
|
+
if (domElement instanceof HTMLElement) {
|
|
23077
|
+
if (domElement instanceof HTMLInputElement) {
|
|
23078
|
+
if (domElement.type === "checkbox") {
|
|
23079
|
+
domElement.checked = !domElement.checked;
|
|
23080
|
+
} else if (domElement.type === "radio") {
|
|
23081
|
+
domElement.checked = true;
|
|
23082
|
+
}
|
|
23083
|
+
domElement.dispatchEvent(new Event("change", { bubbles: true }));
|
|
23084
|
+
} else {
|
|
23085
|
+
domElement.click();
|
|
23086
|
+
}
|
|
23087
|
+
return true;
|
|
23088
|
+
} else {
|
|
23089
|
+
return false;
|
|
22915
23090
|
}
|
|
22916
|
-
|
|
22917
|
-
|
|
23091
|
+
}
|
|
23092
|
+
function findDOMElementById(elementId) {
|
|
23093
|
+
if (!elementId) {
|
|
23094
|
+
return null;
|
|
23095
|
+
}
|
|
23096
|
+
const interactiveElements = getInteractiveElements();
|
|
23097
|
+
for (const element of interactiveElements) {
|
|
23098
|
+
if (element instanceof HTMLElement) {
|
|
23099
|
+
const staticId = element.getAttribute("data-ansyr-static");
|
|
23100
|
+
const dynamicId = element.getAttribute("data-ansyr-dynamic");
|
|
23101
|
+
const currentElementId = staticId || dynamicId || generateStableDOMId(element);
|
|
23102
|
+
if (currentElementId === elementId) {
|
|
23103
|
+
return element;
|
|
23104
|
+
}
|
|
23105
|
+
}
|
|
22918
23106
|
}
|
|
22919
|
-
return
|
|
22920
|
-
|
|
22921
|
-
|
|
22922
|
-
|
|
23107
|
+
return null;
|
|
23108
|
+
}
|
|
23109
|
+
|
|
23110
|
+
// src/utils/webrtc-service.ts
|
|
23111
|
+
var room = null;
|
|
23112
|
+
var reconnectTimeout = null;
|
|
23113
|
+
var serverUrl = WEBRTC_BACKEND_SERVER_URL || "https://bdd4c945f073.ngrok-free.app";
|
|
23114
|
+
var callbacks = {};
|
|
23115
|
+
var audioContainerRef = null;
|
|
23116
|
+
var livekitUrl = null;
|
|
23117
|
+
var token = null;
|
|
23118
|
+
var roomName = null;
|
|
23119
|
+
function setServerUrl(url) {
|
|
23120
|
+
serverUrl = url;
|
|
23121
|
+
}
|
|
23122
|
+
function setAudioContainer(newAudioContainerRef) {
|
|
23123
|
+
audioContainerRef = newAudioContainerRef;
|
|
23124
|
+
}
|
|
23125
|
+
function setWebRTCCallbacks(newCallbacks) {
|
|
23126
|
+
callbacks = newCallbacks;
|
|
23127
|
+
}
|
|
23128
|
+
async function authenticate(userIdentity, apiKey, appId) {
|
|
23129
|
+
try {
|
|
23130
|
+
const authPayload = {
|
|
23131
|
+
user_identity: userIdentity,
|
|
23132
|
+
app_id: appId || _appId
|
|
23133
|
+
};
|
|
23134
|
+
const response = await fetch(`${serverUrl}/auth/login`, {
|
|
23135
|
+
method: "POST",
|
|
23136
|
+
headers: {
|
|
23137
|
+
"Content-Type": "application/json",
|
|
23138
|
+
"X-API-Key": apiKey
|
|
23139
|
+
},
|
|
23140
|
+
body: JSON.stringify(authPayload)
|
|
23141
|
+
});
|
|
23142
|
+
if (!response.ok) {
|
|
23143
|
+
const errorData = await response.json();
|
|
23144
|
+
throw new Error(errorData.detail || "Authentication failed");
|
|
23145
|
+
}
|
|
23146
|
+
const authData = await response.json();
|
|
23147
|
+
livekitUrl = authData.livekit_url;
|
|
23148
|
+
token = authData.livekit_token;
|
|
23149
|
+
roomName = authData.room_name;
|
|
23150
|
+
userIdentity = authData.user_identity;
|
|
23151
|
+
return authData;
|
|
23152
|
+
} catch (error) {
|
|
23153
|
+
throw error;
|
|
23154
|
+
}
|
|
23155
|
+
}
|
|
23156
|
+
async function connectToRoom(newLivekitUrl, newToken) {
|
|
23157
|
+
const url = newLivekitUrl || livekitUrl;
|
|
23158
|
+
const authToken = newToken || token;
|
|
23159
|
+
if (!url || !authToken) {
|
|
23160
|
+
throw new Error("Missing LiveKit URL or token. Please authenticate first.");
|
|
23161
|
+
}
|
|
23162
|
+
try {
|
|
23163
|
+
setWebRTCConnectionState({ isConnected: false, isConnecting: true });
|
|
23164
|
+
room = new Room({
|
|
23165
|
+
adaptiveStream: true,
|
|
23166
|
+
dynacast: true
|
|
23167
|
+
});
|
|
23168
|
+
setupEventListeners();
|
|
23169
|
+
await room.connect(url, authToken);
|
|
23170
|
+
setWebRTCConnectionState({ isConnected: true, isConnecting: false });
|
|
23171
|
+
try {
|
|
23172
|
+
await room.localParticipant.setMicrophoneEnabled(true);
|
|
23173
|
+
} catch (micError) {
|
|
23174
|
+
}
|
|
23175
|
+
return { success: true };
|
|
23176
|
+
} catch (error) {
|
|
23177
|
+
setWebRTCConnectionState({ isConnected: false, isConnecting: false });
|
|
23178
|
+
throw error;
|
|
23179
|
+
}
|
|
23180
|
+
}
|
|
23181
|
+
function setupEventListeners() {
|
|
23182
|
+
if (!room) return;
|
|
23183
|
+
room.on(RoomEvent.ConnectionStateChanged, (state) => {
|
|
23184
|
+
callbacks.onConnectionStateChange?.(state);
|
|
23185
|
+
if (state === ConnectionState.Connected) {
|
|
23186
|
+
setWebRTCConnectionState({ isConnected: true, isConnecting: false });
|
|
23187
|
+
} else if (state === ConnectionState.Disconnected) {
|
|
23188
|
+
setWebRTCConnectionState({ isConnected: false, isConnecting: false });
|
|
23189
|
+
} else if (state === ConnectionState.Connecting) {
|
|
23190
|
+
setWebRTCConnectionState({ isConnected: false, isConnecting: true });
|
|
23191
|
+
}
|
|
23192
|
+
}).on(RoomEvent.ParticipantConnected, (participant) => {
|
|
23193
|
+
updateParticipantsList();
|
|
23194
|
+
}).on(RoomEvent.ParticipantDisconnected, (participant) => {
|
|
23195
|
+
updateParticipantsList();
|
|
23196
|
+
}).on(RoomEvent.TrackSubscribed, (track, publication, participant) => {
|
|
23197
|
+
if (track.kind === Track.Kind.Audio && !participant.isLocal) {
|
|
23198
|
+
const isAIParticipant = participant.identity.toLowerCase().includes("ai") || participant.identity.toLowerCase().includes("bot") || !participant.identity.startsWith("user_");
|
|
23199
|
+
if (isAIParticipant) {
|
|
23200
|
+
const element = track.attach();
|
|
23201
|
+
if (audioContainerRef?.current) {
|
|
23202
|
+
audioContainerRef.current.appendChild(element);
|
|
23203
|
+
if (element instanceof HTMLAudioElement) {
|
|
23204
|
+
const trackId = track.sid || `track_${Date.now()}_${Math.random()}`;
|
|
23205
|
+
callbacks.onAISpeechStart?.(trackId);
|
|
23206
|
+
element.play().catch((error) => {
|
|
23207
|
+
});
|
|
23208
|
+
element.addEventListener("ended", () => callbacks.onAISpeechEnd?.(trackId));
|
|
23209
|
+
element.addEventListener("pause", () => callbacks.onAISpeechEnd?.(trackId));
|
|
23210
|
+
}
|
|
23211
|
+
}
|
|
23212
|
+
}
|
|
23213
|
+
}
|
|
23214
|
+
}).on(RoomEvent.TrackUnsubscribed, (track) => {
|
|
23215
|
+
track.detach().forEach((element) => element.remove());
|
|
23216
|
+
}).on(RoomEvent.DataReceived, (payload, participant) => {
|
|
23217
|
+
const decodedPayload = new TextDecoder().decode(payload);
|
|
23218
|
+
try {
|
|
23219
|
+
const message = JSON.parse(decodedPayload);
|
|
23220
|
+
callbacks.onNavigationCommand?.(message);
|
|
23221
|
+
} catch (error) {
|
|
23222
|
+
const message = decodedPayload;
|
|
23223
|
+
callbacks.onNavigationCommand?.({ type: "raw_text", data: message });
|
|
23224
|
+
}
|
|
23225
|
+
}).on(RoomEvent.Disconnected, () => {
|
|
23226
|
+
setWebRTCConnectionState({ isConnected: false, isConnecting: false });
|
|
23227
|
+
});
|
|
23228
|
+
}
|
|
23229
|
+
function updateParticipantsList() {
|
|
23230
|
+
if (!room) return;
|
|
23231
|
+
const participants = [
|
|
23232
|
+
room.localParticipant.identity,
|
|
23233
|
+
...Array.from(room.remoteParticipants.values()).map((p) => p.identity)
|
|
23234
|
+
];
|
|
23235
|
+
setWebRTCConnectionState({ participants });
|
|
23236
|
+
callbacks.onParticipantUpdate?.(participants);
|
|
23237
|
+
}
|
|
23238
|
+
async function sendData(data, reliable = true) {
|
|
23239
|
+
if (!room) throw new Error("Not connected to room");
|
|
23240
|
+
try {
|
|
23241
|
+
console.log("\u2B06\uFE0F Sending data to backend [DataChannel]:", data);
|
|
23242
|
+
const encoder = new TextEncoder();
|
|
23243
|
+
const encodedData = encoder.encode(data);
|
|
23244
|
+
await room.localParticipant.publishData(encodedData, {
|
|
23245
|
+
reliable
|
|
23246
|
+
});
|
|
23247
|
+
} catch (error) {
|
|
23248
|
+
throw error;
|
|
23249
|
+
}
|
|
23250
|
+
}
|
|
23251
|
+
async function sendScreenStatus(screenData) {
|
|
23252
|
+
try {
|
|
23253
|
+
console.log("\u2B06\uFE0F Sending to backend [/ai/data]:", JSON.stringify(screenData, null, 2));
|
|
23254
|
+
await fetch(`${serverUrl}/ai/data`, {
|
|
23255
|
+
method: "POST",
|
|
23256
|
+
headers: { "Content-Type": "application/json" },
|
|
23257
|
+
body: JSON.stringify(screenData)
|
|
23258
|
+
});
|
|
23259
|
+
} catch (error) {
|
|
23260
|
+
throw error;
|
|
23261
|
+
}
|
|
23262
|
+
}
|
|
23263
|
+
function isConnected() {
|
|
23264
|
+
return room?.state === ConnectionState.Connected;
|
|
23265
|
+
}
|
|
23266
|
+
function getRoomName() {
|
|
23267
|
+
return roomName;
|
|
23268
|
+
}
|
|
23269
|
+
function getParticipants() {
|
|
23270
|
+
return Array.from(room?.remoteParticipants.values() ?? []);
|
|
23271
|
+
}
|
|
23272
|
+
async function sendUserCommand(command) {
|
|
23273
|
+
if (!room) return;
|
|
23274
|
+
await sendData(command);
|
|
23275
|
+
}
|
|
23276
|
+
async function sendRuntimeData() {
|
|
23277
|
+
if (!room) {
|
|
23278
|
+
return;
|
|
23279
|
+
}
|
|
23280
|
+
try {
|
|
23281
|
+
const domStructure = captureFullDOMStructure();
|
|
23282
|
+
const screenName = getCurrentScreenName();
|
|
23283
|
+
const response = {
|
|
23284
|
+
type: "runtime_data_response",
|
|
23285
|
+
data: {
|
|
23286
|
+
components: domStructure.components,
|
|
23287
|
+
current_screen: screenName
|
|
23288
|
+
}
|
|
23289
|
+
};
|
|
23290
|
+
await sendData(JSON.stringify(response));
|
|
23291
|
+
} catch (error) {
|
|
23292
|
+
}
|
|
23293
|
+
}
|
|
23294
|
+
async function sendStaticData(componentData, appId = "default") {
|
|
23295
|
+
try {
|
|
23296
|
+
const staticDataPayload = {
|
|
23297
|
+
type: "dashboard_data",
|
|
23298
|
+
app_id: appId,
|
|
23299
|
+
data: componentData
|
|
23300
|
+
};
|
|
23301
|
+
console.log("\u2B06\uFE0F Sending to backend [/ai/data]:", JSON.stringify(staticDataPayload, null, 2));
|
|
23302
|
+
const response = await fetch(`${serverUrl}/ai/data`, {
|
|
23303
|
+
method: "POST",
|
|
23304
|
+
headers: {
|
|
23305
|
+
"Content-Type": "application/json"
|
|
23306
|
+
},
|
|
23307
|
+
body: JSON.stringify(staticDataPayload)
|
|
23308
|
+
});
|
|
23309
|
+
if (response.ok) {
|
|
23310
|
+
const result = await response.json();
|
|
23311
|
+
console.log("\u2B07\uFE0F Received from backend [/ai/data]:", JSON.stringify(result, null, 2));
|
|
23312
|
+
return { success: true, data: result };
|
|
23313
|
+
} else {
|
|
23314
|
+
const errorText = await response.text();
|
|
23315
|
+
return { success: false, error: `HTTP ${response.status}: ${errorText}` };
|
|
23316
|
+
}
|
|
23317
|
+
} catch (error) {
|
|
23318
|
+
return { success: false, error: error instanceof Error ? error.message : "Network error" };
|
|
23319
|
+
}
|
|
23320
|
+
}
|
|
23321
|
+
async function disconnectFromRoom() {
|
|
23322
|
+
if (room) {
|
|
23323
|
+
await room.disconnect();
|
|
23324
|
+
room = null;
|
|
23325
|
+
}
|
|
23326
|
+
if (reconnectTimeout) {
|
|
23327
|
+
clearTimeout(reconnectTimeout);
|
|
23328
|
+
reconnectTimeout = null;
|
|
23329
|
+
}
|
|
23330
|
+
setWebRTCConnectionState({
|
|
23331
|
+
isConnected: false,
|
|
23332
|
+
isConnecting: false,
|
|
23333
|
+
participants: []
|
|
23334
|
+
});
|
|
22923
23335
|
}
|
|
22924
|
-
function
|
|
22925
|
-
|
|
22926
|
-
return item === void 0 || allowedValues.includes(item);
|
|
23336
|
+
function getRoom() {
|
|
23337
|
+
return room;
|
|
22927
23338
|
}
|
|
22928
23339
|
|
|
22929
23340
|
export {
|
|
22930
|
-
|
|
22931
|
-
|
|
22932
|
-
|
|
22933
|
-
|
|
22934
|
-
|
|
22935
|
-
|
|
22936
|
-
|
|
22937
|
-
|
|
22938
|
-
|
|
22939
|
-
|
|
22940
|
-
|
|
22941
|
-
|
|
22942
|
-
|
|
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,
|
|
23341
|
+
__require,
|
|
23342
|
+
__commonJS,
|
|
23343
|
+
__export,
|
|
23344
|
+
__toESM,
|
|
23345
|
+
_apiKey,
|
|
23346
|
+
_appId,
|
|
23347
|
+
setApiKey,
|
|
23348
|
+
setAppId,
|
|
23349
|
+
setWebRTCConfig,
|
|
23350
|
+
GlobalStore,
|
|
23351
|
+
setNavigationHandler,
|
|
23352
|
+
onStateChange,
|
|
23353
|
+
WEBRTC_BACKEND_SERVER_URL,
|
|
22975
23354
|
RoomEvent,
|
|
22976
23355
|
ParticipantEvent,
|
|
22977
|
-
EngineEvent,
|
|
22978
|
-
TrackEvent,
|
|
22979
|
-
getBrowser,
|
|
22980
|
-
version,
|
|
22981
|
-
protocolVersion,
|
|
22982
|
-
CriticalTimers,
|
|
22983
|
-
VideoQuality,
|
|
22984
23356
|
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,
|
|
23003
23357
|
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,
|
|
23025
|
-
Participant,
|
|
23026
|
-
LocalParticipant,
|
|
23027
|
-
RemoteTrackPublication,
|
|
23028
|
-
RemoteParticipant,
|
|
23029
23358
|
ConnectionState,
|
|
23030
|
-
|
|
23031
|
-
|
|
23032
|
-
|
|
23033
|
-
|
|
23034
|
-
|
|
23035
|
-
|
|
23036
|
-
|
|
23359
|
+
captureFullDOMStructure,
|
|
23360
|
+
executeAction,
|
|
23361
|
+
getFullDOMStructure,
|
|
23362
|
+
setServerUrl,
|
|
23363
|
+
setAudioContainer,
|
|
23364
|
+
setWebRTCCallbacks,
|
|
23365
|
+
authenticate,
|
|
23366
|
+
connectToRoom,
|
|
23367
|
+
sendData,
|
|
23368
|
+
sendScreenStatus,
|
|
23369
|
+
isConnected,
|
|
23370
|
+
getRoomName,
|
|
23371
|
+
getParticipants,
|
|
23372
|
+
sendUserCommand,
|
|
23373
|
+
sendRuntimeData,
|
|
23374
|
+
sendStaticData,
|
|
23375
|
+
disconnectFromRoom,
|
|
23376
|
+
getRoom
|
|
23037
23377
|
};
|