livekit-client 2.3.2 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +8 -6
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +268 -45
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts +5 -2
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/reconnect.d.ts.map +1 -1
- package/dist/src/e2ee/errors.d.ts +2 -1
- package/dist/src/e2ee/errors.d.ts.map +1 -1
- package/dist/src/e2ee/index.d.ts +1 -0
- package/dist/src/e2ee/index.d.ts.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +2 -1
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +2 -0
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/errors.d.ts +5 -0
- package/dist/src/room/errors.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +15 -2
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +14 -6
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +8 -0
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/timers.d.ts +4 -4
- package/dist/src/room/timers.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +1 -0
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +5 -2
- package/dist/ts4.2/src/e2ee/errors.d.ts +2 -1
- package/dist/ts4.2/src/e2ee/index.d.ts +1 -0
- package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -1
- package/dist/ts4.2/src/room/Room.d.ts +2 -0
- package/dist/ts4.2/src/room/errors.d.ts +5 -0
- package/dist/ts4.2/src/room/events.d.ts +15 -2
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +14 -6
- package/dist/ts4.2/src/room/participant/Participant.d.ts +8 -0
- package/dist/ts4.2/src/room/timers.d.ts +4 -4
- package/dist/ts4.2/src/room/track/utils.d.ts +1 -0
- package/package.json +2 -2
- package/src/api/SignalClient.ts +24 -2
- package/src/connectionHelper/checks/reconnect.ts +6 -3
- package/src/e2ee/errors.ts +8 -1
- package/src/e2ee/index.ts +1 -0
- package/src/e2ee/worker/FrameCryptor.ts +15 -3
- package/src/logger.ts +4 -3
- package/src/room/DeviceManager.ts +1 -1
- package/src/room/RTCEngine.ts +3 -0
- package/src/room/Room.ts +25 -3
- package/src/room/errors.ts +11 -0
- package/src/room/events.ts +15 -0
- package/src/room/participant/LocalParticipant.ts +92 -10
- package/src/room/participant/Participant.ts +23 -0
- package/src/room/track/utils.test.ts +35 -1
- package/src/room/track/utils.ts +22 -0
@@ -4740,6 +4740,12 @@ const SignalResponse = /*@__PURE__*/proto3.makeMessageType("livekit.SignalRespon
|
|
4740
4740
|
kind: "message",
|
4741
4741
|
T: SubscriptionResponse,
|
4742
4742
|
oneof: "message"
|
4743
|
+
}, {
|
4744
|
+
no: 22,
|
4745
|
+
name: "error_response",
|
4746
|
+
kind: "message",
|
4747
|
+
T: ErrorResponse,
|
4748
|
+
oneof: "message"
|
4743
4749
|
}]);
|
4744
4750
|
|
4745
4751
|
/**
|
@@ -5189,6 +5195,11 @@ const UpdateParticipantMetadata = /*@__PURE__*/proto3.makeMessageType("livekit.U
|
|
5189
5195
|
kind: "scalar",
|
5190
5196
|
T: 9 /* ScalarType.STRING */
|
5191
5197
|
}
|
5198
|
+
}, {
|
5199
|
+
no: 4,
|
5200
|
+
name: "request_id",
|
5201
|
+
kind: "scalar",
|
5202
|
+
T: 13 /* ScalarType.UINT32 */
|
5192
5203
|
}]);
|
5193
5204
|
|
5194
5205
|
/**
|
@@ -5603,6 +5614,43 @@ const SubscriptionResponse = /*@__PURE__*/proto3.makeMessageType("livekit.Subscr
|
|
5603
5614
|
T: proto3.getEnumType(SubscriptionError)
|
5604
5615
|
}]);
|
5605
5616
|
|
5617
|
+
/**
|
5618
|
+
* @generated from message livekit.ErrorResponse
|
5619
|
+
*/
|
5620
|
+
const ErrorResponse = /*@__PURE__*/proto3.makeMessageType("livekit.ErrorResponse", () => [{
|
5621
|
+
no: 1,
|
5622
|
+
name: "request_id",
|
5623
|
+
kind: "scalar",
|
5624
|
+
T: 13 /* ScalarType.UINT32 */
|
5625
|
+
}, {
|
5626
|
+
no: 2,
|
5627
|
+
name: "reason",
|
5628
|
+
kind: "enum",
|
5629
|
+
T: proto3.getEnumType(ErrorResponse_Reason)
|
5630
|
+
}, {
|
5631
|
+
no: 3,
|
5632
|
+
name: "message",
|
5633
|
+
kind: "scalar",
|
5634
|
+
T: 9 /* ScalarType.STRING */
|
5635
|
+
}]);
|
5636
|
+
|
5637
|
+
/**
|
5638
|
+
* @generated from enum livekit.ErrorResponse.Reason
|
5639
|
+
*/
|
5640
|
+
const ErrorResponse_Reason = /*@__PURE__*/proto3.makeEnum("livekit.ErrorResponse.Reason", [{
|
5641
|
+
no: 0,
|
5642
|
+
name: "UNKNOWN"
|
5643
|
+
}, {
|
5644
|
+
no: 1,
|
5645
|
+
name: "NOT_FOUND"
|
5646
|
+
}, {
|
5647
|
+
no: 2,
|
5648
|
+
name: "NOT_ALLOWED"
|
5649
|
+
}, {
|
5650
|
+
no: 3,
|
5651
|
+
name: "INVALID_ARGUMENT"
|
5652
|
+
}]);
|
5653
|
+
|
5606
5654
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
5607
5655
|
|
5608
5656
|
function getDefaultExportFromCjs (x) {
|
@@ -5963,9 +6011,10 @@ function getLogger(name) {
|
|
5963
6011
|
function setLogLevel(level, loggerName) {
|
5964
6012
|
if (loggerName) {
|
5965
6013
|
loglevelExports.getLogger(loggerName).setLevel(level);
|
5966
|
-
}
|
5967
|
-
|
5968
|
-
|
6014
|
+
} else {
|
6015
|
+
for (const logger of livekitLoggers) {
|
6016
|
+
logger.setLevel(level);
|
6017
|
+
}
|
5969
6018
|
}
|
5970
6019
|
}
|
5971
6020
|
/**
|
@@ -9768,6 +9817,13 @@ class PublishDataError extends LivekitError {
|
|
9768
9817
|
super(13, message !== null && message !== void 0 ? message : 'unable to publish data');
|
9769
9818
|
}
|
9770
9819
|
}
|
9820
|
+
class SignalRequestError extends LivekitError {
|
9821
|
+
constructor(message) {
|
9822
|
+
let reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ErrorResponse_Reason.UNKNOWN;
|
9823
|
+
super(15, message);
|
9824
|
+
this.reason = reason;
|
9825
|
+
}
|
9826
|
+
}
|
9771
9827
|
var MediaDeviceFailure;
|
9772
9828
|
(function (MediaDeviceFailure) {
|
9773
9829
|
// user rejected permissions
|
@@ -9796,6 +9852,22 @@ var MediaDeviceFailure;
|
|
9796
9852
|
MediaDeviceFailure.getFailure = getFailure;
|
9797
9853
|
})(MediaDeviceFailure || (MediaDeviceFailure = {}));
|
9798
9854
|
|
9855
|
+
var CryptorErrorReason;
|
9856
|
+
(function (CryptorErrorReason) {
|
9857
|
+
CryptorErrorReason[CryptorErrorReason["InvalidKey"] = 0] = "InvalidKey";
|
9858
|
+
CryptorErrorReason[CryptorErrorReason["MissingKey"] = 1] = "MissingKey";
|
9859
|
+
CryptorErrorReason[CryptorErrorReason["InternalError"] = 2] = "InternalError";
|
9860
|
+
})(CryptorErrorReason || (CryptorErrorReason = {}));
|
9861
|
+
class CryptorError extends LivekitError {
|
9862
|
+
constructor(message) {
|
9863
|
+
let reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CryptorErrorReason.InternalError;
|
9864
|
+
let participantIdentity = arguments.length > 2 ? arguments[2] : undefined;
|
9865
|
+
super(40, message);
|
9866
|
+
this.reason = reason;
|
9867
|
+
this.participantIdentity = participantIdentity;
|
9868
|
+
}
|
9869
|
+
}
|
9870
|
+
|
9799
9871
|
/**
|
9800
9872
|
* Events are the primary way LiveKit notifies your application of changes.
|
9801
9873
|
*
|
@@ -9961,6 +10033,12 @@ var RoomEvent;
|
|
9961
10033
|
*
|
9962
10034
|
*/
|
9963
10035
|
RoomEvent["ParticipantNameChanged"] = "participantNameChanged";
|
10036
|
+
/**
|
10037
|
+
* Participant attributes is an app-specific key value state to be pushed to
|
10038
|
+
* all users.
|
10039
|
+
* When a participant's attributes changed, this event will be emitted with the changed attributes and the participant
|
10040
|
+
*/
|
10041
|
+
RoomEvent["ParticipantAttributesChanged"] = "participantAttributesChanged";
|
9964
10042
|
/**
|
9965
10043
|
* Room metadata is a simple way for app-specific state to be pushed to
|
9966
10044
|
* all users.
|
@@ -10233,6 +10311,12 @@ var ParticipantEvent;
|
|
10233
10311
|
ParticipantEvent["ParticipantPermissionsChanged"] = "participantPermissionsChanged";
|
10234
10312
|
/** @internal */
|
10235
10313
|
ParticipantEvent["PCTrackAdded"] = "pcTrackAdded";
|
10314
|
+
/**
|
10315
|
+
* Participant attributes is an app-specific key value state to be pushed to
|
10316
|
+
* all users.
|
10317
|
+
* When a participant's attributes changed, this event will be emitted with the changed attributes
|
10318
|
+
*/
|
10319
|
+
ParticipantEvent["AttributesChanged"] = "attributesChanged";
|
10236
10320
|
})(ParticipantEvent || (ParticipantEvent = {}));
|
10237
10321
|
/** @internal */
|
10238
10322
|
var EngineEvent;
|
@@ -10263,6 +10347,7 @@ var EngineEvent;
|
|
10263
10347
|
EngineEvent["SubscribedQualityUpdate"] = "subscribedQualityUpdate";
|
10264
10348
|
EngineEvent["LocalTrackUnpublished"] = "localTrackUnpublished";
|
10265
10349
|
EngineEvent["Offline"] = "offline";
|
10350
|
+
EngineEvent["SignalRequestError"] = "signalRequestError";
|
10266
10351
|
})(EngineEvent || (EngineEvent = {}));
|
10267
10352
|
var TrackEvent;
|
10268
10353
|
(function (TrackEvent) {
|
@@ -10454,7 +10539,7 @@ function getOSVersion(ua) {
|
|
10454
10539
|
return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
|
10455
10540
|
}
|
10456
10541
|
|
10457
|
-
var version$1 = "2.
|
10542
|
+
var version$1 = "2.4.1";
|
10458
10543
|
|
10459
10544
|
const version = version$1;
|
10460
10545
|
const protocolVersion = 13;
|
@@ -11161,6 +11246,23 @@ function getLogContextFromTrack(track) {
|
|
11161
11246
|
function supportsSynchronizationSources() {
|
11162
11247
|
return typeof RTCRtpReceiver !== 'undefined' && 'getSynchronizationSources' in RTCRtpReceiver;
|
11163
11248
|
}
|
11249
|
+
function diffAttributes(oldValues, newValues) {
|
11250
|
+
var _a;
|
11251
|
+
if (oldValues === undefined) {
|
11252
|
+
oldValues = {};
|
11253
|
+
}
|
11254
|
+
if (newValues === undefined) {
|
11255
|
+
newValues = {};
|
11256
|
+
}
|
11257
|
+
const allKeys = [...Object.keys(newValues), ...Object.keys(oldValues)];
|
11258
|
+
const diff = {};
|
11259
|
+
for (const key of allKeys) {
|
11260
|
+
if (oldValues[key] !== newValues[key]) {
|
11261
|
+
diff[key] = (_a = newValues[key]) !== null && _a !== void 0 ? _a : '';
|
11262
|
+
}
|
11263
|
+
}
|
11264
|
+
return diff;
|
11265
|
+
}
|
11164
11266
|
|
11165
11267
|
const separator = '|';
|
11166
11268
|
const ddExtensionURI = 'https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension';
|
@@ -11616,7 +11718,7 @@ class DeviceManager {
|
|
11616
11718
|
if (requestPermissions &&
|
11617
11719
|
// for safari we need to skip this check, as otherwise it will re-acquire user media and fail on iOS https://bugs.webkit.org/show_bug.cgi?id=179363
|
11618
11720
|
!(isSafari() && _this.hasDeviceInUse(kind))) {
|
11619
|
-
const isDummyDeviceOrEmpty = devices.length === 0 || devices.some(device => {
|
11721
|
+
const isDummyDeviceOrEmpty = devices.filter(d => d.kind === kind).length === 0 || devices.some(device => {
|
11620
11722
|
const noLabel = device.label === '';
|
11621
11723
|
const isRelevant = kind ? device.kind === kind : true;
|
11622
11724
|
return noLabel && isRelevant;
|
@@ -12559,6 +12661,10 @@ class SignalClient {
|
|
12559
12661
|
get isEstablishingConnection() {
|
12560
12662
|
return this.state === SignalConnectionState.CONNECTING || this.state === SignalConnectionState.RECONNECTING;
|
12561
12663
|
}
|
12664
|
+
getNextRequestId() {
|
12665
|
+
this._requestId += 1;
|
12666
|
+
return this._requestId;
|
12667
|
+
}
|
12562
12668
|
constructor() {
|
12563
12669
|
let useJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
12564
12670
|
let loggerOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
@@ -12567,6 +12673,7 @@ class SignalClient {
|
|
12567
12673
|
this.rtt = 0;
|
12568
12674
|
this.state = SignalConnectionState.DISCONNECTED;
|
12569
12675
|
this.log = livekitLogger;
|
12676
|
+
this._requestId = 0;
|
12570
12677
|
/** @internal */
|
12571
12678
|
this.resetCallbacks = () => {
|
12572
12679
|
this.onAnswer = undefined;
|
@@ -12837,13 +12944,23 @@ class SignalClient {
|
|
12837
12944
|
value: req
|
12838
12945
|
});
|
12839
12946
|
}
|
12840
|
-
sendUpdateLocalMetadata(
|
12841
|
-
return this
|
12842
|
-
|
12843
|
-
|
12844
|
-
|
12845
|
-
|
12846
|
-
|
12947
|
+
sendUpdateLocalMetadata(metadata_1, name_1) {
|
12948
|
+
return __awaiter(this, arguments, void 0, function (metadata, name) {
|
12949
|
+
var _this2 = this;
|
12950
|
+
let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
12951
|
+
return function* () {
|
12952
|
+
const requestId = _this2.getNextRequestId();
|
12953
|
+
yield _this2.sendRequest({
|
12954
|
+
case: 'updateMetadata',
|
12955
|
+
value: new UpdateParticipantMetadata({
|
12956
|
+
requestId,
|
12957
|
+
metadata,
|
12958
|
+
name,
|
12959
|
+
attributes
|
12960
|
+
})
|
12961
|
+
});
|
12962
|
+
return requestId;
|
12963
|
+
}();
|
12847
12964
|
});
|
12848
12965
|
}
|
12849
12966
|
sendUpdateTrackSettings(settings) {
|
@@ -12922,40 +13039,40 @@ class SignalClient {
|
|
12922
13039
|
}
|
12923
13040
|
sendRequest(message_1) {
|
12924
13041
|
return __awaiter(this, arguments, void 0, function (message) {
|
12925
|
-
var
|
13042
|
+
var _this3 = this;
|
12926
13043
|
let fromQueue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
12927
13044
|
return function* () {
|
12928
13045
|
// capture all requests while reconnecting and put them in a queue
|
12929
13046
|
// unless the request originates from the queue, then don't enqueue again
|
12930
13047
|
const canQueue = !fromQueue && !canPassThroughQueue(message);
|
12931
|
-
if (canQueue &&
|
12932
|
-
|
13048
|
+
if (canQueue && _this3.state === SignalConnectionState.RECONNECTING) {
|
13049
|
+
_this3.queuedRequests.push(() => __awaiter(_this3, void 0, void 0, function* () {
|
12933
13050
|
yield this.sendRequest(message, true);
|
12934
13051
|
}));
|
12935
13052
|
return;
|
12936
13053
|
}
|
12937
13054
|
// make sure previously queued requests are being sent first
|
12938
13055
|
if (!fromQueue) {
|
12939
|
-
yield
|
13056
|
+
yield _this3.requestQueue.flush();
|
12940
13057
|
}
|
12941
|
-
if (
|
12942
|
-
yield sleep(
|
13058
|
+
if (_this3.signalLatency) {
|
13059
|
+
yield sleep(_this3.signalLatency);
|
12943
13060
|
}
|
12944
|
-
if (!
|
12945
|
-
|
13061
|
+
if (!_this3.ws || _this3.ws.readyState !== _this3.ws.OPEN) {
|
13062
|
+
_this3.log.error("cannot send signal request before connected, type: ".concat(message === null || message === void 0 ? void 0 : message.case), _this3.logContext);
|
12946
13063
|
return;
|
12947
13064
|
}
|
12948
13065
|
const req = new SignalRequest({
|
12949
13066
|
message
|
12950
13067
|
});
|
12951
13068
|
try {
|
12952
|
-
if (
|
12953
|
-
|
13069
|
+
if (_this3.useJSON) {
|
13070
|
+
_this3.ws.send(req.toJsonString());
|
12954
13071
|
} else {
|
12955
|
-
|
13072
|
+
_this3.ws.send(req.toBinary());
|
12956
13073
|
}
|
12957
13074
|
} catch (e) {
|
12958
|
-
|
13075
|
+
_this3.log.error('error sending signal message', Object.assign(Object.assign({}, _this3.logContext), {
|
12959
13076
|
error: e
|
12960
13077
|
}));
|
12961
13078
|
}
|
@@ -13041,6 +13158,10 @@ class SignalClient {
|
|
13041
13158
|
this.rtt = Date.now() - Number.parseInt(msg.value.lastPingTimestamp.toString());
|
13042
13159
|
this.resetPingTimeout();
|
13043
13160
|
pingHandled = true;
|
13161
|
+
} else if (msg.case === 'errorResponse') {
|
13162
|
+
if (this.onErrorResponse) {
|
13163
|
+
this.onErrorResponse(msg.value);
|
13164
|
+
}
|
13044
13165
|
} else {
|
13045
13166
|
this.log.debug('unsupported message', Object.assign(Object.assign({}, this.logContext), {
|
13046
13167
|
msgCase: msg.case
|
@@ -16090,6 +16211,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
16090
16211
|
this.client.onSubscriptionPermissionUpdate = update => this.emit(EngineEvent.SubscriptionPermissionUpdate, update);
|
16091
16212
|
this.client.onSpeakersChanged = update => this.emit(EngineEvent.SpeakersChanged, update);
|
16092
16213
|
this.client.onStreamStateUpdate = update => this.emit(EngineEvent.StreamStateChanged, update);
|
16214
|
+
this.client.onErrorResponse = error => this.emit(EngineEvent.SignalRequestError, error);
|
16093
16215
|
}
|
16094
16216
|
/** @internal */
|
16095
16217
|
get logContext() {
|
@@ -17898,6 +18020,10 @@ class Participant extends eventsExports.EventEmitter {
|
|
17898
18020
|
get kind() {
|
17899
18021
|
return this._kind;
|
17900
18022
|
}
|
18023
|
+
/** participant attributes, similar to metadata, but as a key/value map */
|
18024
|
+
get attributes() {
|
18025
|
+
return Object.freeze(Object.assign({}, this._attributes));
|
18026
|
+
}
|
17901
18027
|
/** @internal */
|
17902
18028
|
constructor(sid, identity, name, metadata, loggerOptions) {
|
17903
18029
|
let kind = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : ParticipantInfo_Kind.STANDARD;
|
@@ -17920,6 +18046,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
17920
18046
|
this.videoTrackPublications = new Map();
|
17921
18047
|
this.trackPublications = new Map();
|
17922
18048
|
this._kind = kind;
|
18049
|
+
this._attributes = {};
|
17923
18050
|
}
|
17924
18051
|
getTrackPublications() {
|
17925
18052
|
return Array.from(this.trackPublications.values());
|
@@ -17987,6 +18114,7 @@ class Participant extends eventsExports.EventEmitter {
|
|
17987
18114
|
this.sid = info.sid;
|
17988
18115
|
this._setName(info.name);
|
17989
18116
|
this._setMetadata(info.metadata);
|
18117
|
+
this._setAttributes(info.attributes);
|
17990
18118
|
if (info.permission) {
|
17991
18119
|
this.setPermissions(info.permission);
|
17992
18120
|
}
|
@@ -18015,6 +18143,16 @@ class Participant extends eventsExports.EventEmitter {
|
|
18015
18143
|
this.emit(ParticipantEvent.ParticipantNameChanged, name);
|
18016
18144
|
}
|
18017
18145
|
}
|
18146
|
+
/**
|
18147
|
+
* Updates metadata from server
|
18148
|
+
**/
|
18149
|
+
_setAttributes(attributes) {
|
18150
|
+
const diff = diffAttributes(attributes, this.attributes);
|
18151
|
+
this._attributes = attributes;
|
18152
|
+
if (Object.keys(diff).length > 0) {
|
18153
|
+
this.emit(ParticipantEvent.AttributesChanged, diff);
|
18154
|
+
}
|
18155
|
+
}
|
18018
18156
|
/** @internal */
|
18019
18157
|
setPermissions(permissions) {
|
18020
18158
|
var _a, _b, _c, _d, _e;
|
@@ -18123,6 +18261,18 @@ class LocalParticipant extends Participant {
|
|
18123
18261
|
this.reconnectFuture = undefined;
|
18124
18262
|
}
|
18125
18263
|
};
|
18264
|
+
this.handleSignalRequestError = error => {
|
18265
|
+
const {
|
18266
|
+
requestId,
|
18267
|
+
reason,
|
18268
|
+
message
|
18269
|
+
} = error;
|
18270
|
+
const failedRequest = this.pendingSignalRequests.get(requestId);
|
18271
|
+
if (failedRequest) {
|
18272
|
+
failedRequest.reject(new SignalRequestError(message, reason));
|
18273
|
+
this.pendingSignalRequests.delete(requestId);
|
18274
|
+
}
|
18275
|
+
};
|
18126
18276
|
this.updateTrackSubscriptionPermissions = () => {
|
18127
18277
|
this.log.debug('updating track subscription permissions', Object.assign(Object.assign({}, this.logContext), {
|
18128
18278
|
allParticipantsAllowed: this.allParticipantsAllowedToSubscribe,
|
@@ -18264,6 +18414,7 @@ class LocalParticipant extends Participant {
|
|
18264
18414
|
this.roomOptions = options;
|
18265
18415
|
this.setupEngine(engine);
|
18266
18416
|
this.activeDeviceMap = new Map();
|
18417
|
+
this.pendingSignalRequests = new Map();
|
18267
18418
|
}
|
18268
18419
|
get lastCameraError() {
|
18269
18420
|
return this.cameraError;
|
@@ -18302,29 +18453,92 @@ class LocalParticipant extends Participant {
|
|
18302
18453
|
pub.unmute();
|
18303
18454
|
}
|
18304
18455
|
});
|
18305
|
-
this.engine.on(EngineEvent.Connected, this.handleReconnected).on(EngineEvent.SignalRestarted, this.handleReconnected).on(EngineEvent.SignalResumed, this.handleReconnected).on(EngineEvent.Restarting, this.handleReconnecting).on(EngineEvent.Resuming, this.handleReconnecting).on(EngineEvent.LocalTrackUnpublished, this.handleLocalTrackUnpublished).on(EngineEvent.SubscribedQualityUpdate, this.handleSubscribedQualityUpdate).on(EngineEvent.Disconnected, this.handleDisconnected);
|
18456
|
+
this.engine.on(EngineEvent.Connected, this.handleReconnected).on(EngineEvent.SignalRestarted, this.handleReconnected).on(EngineEvent.SignalResumed, this.handleReconnected).on(EngineEvent.Restarting, this.handleReconnecting).on(EngineEvent.Resuming, this.handleReconnecting).on(EngineEvent.LocalTrackUnpublished, this.handleLocalTrackUnpublished).on(EngineEvent.SubscribedQualityUpdate, this.handleSubscribedQualityUpdate).on(EngineEvent.Disconnected, this.handleDisconnected).on(EngineEvent.SignalRequestError, this.handleSignalRequestError);
|
18306
18457
|
}
|
18307
18458
|
/**
|
18308
18459
|
* Sets and updates the metadata of the local participant.
|
18309
|
-
* The change does not take immediate effect.
|
18310
|
-
* If successful, a `ParticipantEvent.MetadataChanged` event will be emitted on the local participant.
|
18311
18460
|
* Note: this requires `canUpdateOwnMetadata` permission.
|
18461
|
+
* method will throw if the user doesn't have the required permissions
|
18312
18462
|
* @param metadata
|
18313
18463
|
*/
|
18314
18464
|
setMetadata(metadata) {
|
18315
|
-
|
18316
|
-
|
18465
|
+
return __awaiter(this, void 0, void 0, function* () {
|
18466
|
+
yield this.requestMetadataUpdate({
|
18467
|
+
metadata
|
18468
|
+
});
|
18469
|
+
});
|
18317
18470
|
}
|
18318
18471
|
/**
|
18319
18472
|
* Sets and updates the name of the local participant.
|
18320
|
-
* The change does not take immediate effect.
|
18321
|
-
* If successful, a `ParticipantEvent.ParticipantNameChanged` event will be emitted on the local participant.
|
18322
18473
|
* Note: this requires `canUpdateOwnMetadata` permission.
|
18474
|
+
* method will throw if the user doesn't have the required permissions
|
18323
18475
|
* @param metadata
|
18324
18476
|
*/
|
18325
18477
|
setName(name) {
|
18326
|
-
|
18327
|
-
|
18478
|
+
return __awaiter(this, void 0, void 0, function* () {
|
18479
|
+
yield this.requestMetadataUpdate({
|
18480
|
+
name
|
18481
|
+
});
|
18482
|
+
});
|
18483
|
+
}
|
18484
|
+
/**
|
18485
|
+
* Set or update participant attributes. It will make updates only to keys that
|
18486
|
+
* are present in `attributes`, and will not override others.
|
18487
|
+
* Note: this requires `canUpdateOwnMetadata` permission.
|
18488
|
+
* @param attributes attributes to update
|
18489
|
+
*/
|
18490
|
+
setAttributes(attributes) {
|
18491
|
+
return __awaiter(this, void 0, void 0, function* () {
|
18492
|
+
yield this.requestMetadataUpdate({
|
18493
|
+
attributes
|
18494
|
+
});
|
18495
|
+
});
|
18496
|
+
}
|
18497
|
+
requestMetadataUpdate(_a) {
|
18498
|
+
return __awaiter(this, arguments, void 0, function (_ref) {
|
18499
|
+
var _this = this;
|
18500
|
+
let {
|
18501
|
+
metadata,
|
18502
|
+
name,
|
18503
|
+
attributes
|
18504
|
+
} = _ref;
|
18505
|
+
return function* () {
|
18506
|
+
return new Promise((resolve, reject) => __awaiter(_this, void 0, void 0, function* () {
|
18507
|
+
var _a, _b;
|
18508
|
+
try {
|
18509
|
+
let isRejected = false;
|
18510
|
+
const requestId = yield this.engine.client.sendUpdateLocalMetadata((_a = metadata !== null && metadata !== void 0 ? metadata : this.metadata) !== null && _a !== void 0 ? _a : '', (_b = name !== null && name !== void 0 ? name : this.name) !== null && _b !== void 0 ? _b : '', attributes);
|
18511
|
+
const startTime = performance.now();
|
18512
|
+
this.pendingSignalRequests.set(requestId, {
|
18513
|
+
resolve,
|
18514
|
+
reject: error => {
|
18515
|
+
reject(error);
|
18516
|
+
isRejected = true;
|
18517
|
+
},
|
18518
|
+
values: {
|
18519
|
+
name,
|
18520
|
+
metadata,
|
18521
|
+
attributes
|
18522
|
+
}
|
18523
|
+
});
|
18524
|
+
while (performance.now() - startTime < 5000 && !isRejected) {
|
18525
|
+
if ((!name || this.name === name) && (!metadata || this.metadata === metadata) && (!attributes || Object.entries(attributes).every(_ref2 => {
|
18526
|
+
let [key, value] = _ref2;
|
18527
|
+
return this.attributes[key] === value;
|
18528
|
+
}))) {
|
18529
|
+
this.pendingSignalRequests.delete(requestId);
|
18530
|
+
resolve();
|
18531
|
+
return;
|
18532
|
+
}
|
18533
|
+
yield sleep(50);
|
18534
|
+
}
|
18535
|
+
reject(new SignalRequestError('Request to update local metadata timed out'));
|
18536
|
+
} catch (e) {
|
18537
|
+
if (e instanceof Error) reject(e);
|
18538
|
+
}
|
18539
|
+
}));
|
18540
|
+
}();
|
18541
|
+
});
|
18328
18542
|
}
|
18329
18543
|
/**
|
18330
18544
|
* Enable or disable a participant's camera track.
|
@@ -19052,11 +19266,11 @@ class LocalParticipant extends Participant {
|
|
19052
19266
|
}
|
19053
19267
|
republishAllTracks(options_1) {
|
19054
19268
|
return __awaiter(this, arguments, void 0, function (options) {
|
19055
|
-
var
|
19269
|
+
var _this2 = this;
|
19056
19270
|
let restartTracks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
19057
19271
|
return function* () {
|
19058
19272
|
const localPubs = [];
|
19059
|
-
|
19273
|
+
_this2.trackPublications.forEach(pub => {
|
19060
19274
|
if (pub.track) {
|
19061
19275
|
if (options) {
|
19062
19276
|
pub.options = Object.assign(Object.assign({}, pub.options), options);
|
@@ -19064,7 +19278,7 @@ class LocalParticipant extends Participant {
|
|
19064
19278
|
localPubs.push(pub);
|
19065
19279
|
}
|
19066
19280
|
});
|
19067
|
-
yield Promise.all(localPubs.map(pub => __awaiter(
|
19281
|
+
yield Promise.all(localPubs.map(pub => __awaiter(_this2, void 0, void 0, function* () {
|
19068
19282
|
const track = pub.track;
|
19069
19283
|
yield this.unpublishTrack(track, false);
|
19070
19284
|
if (restartTracks && !track.isMuted && track.source !== Track.Source.ScreenShare && track.source !== Track.Source.ScreenShareAudio && (track instanceof LocalAudioTrack || track instanceof LocalVideoTrack) && !track.isUserProvided) {
|
@@ -19089,7 +19303,7 @@ class LocalParticipant extends Participant {
|
|
19089
19303
|
*/
|
19090
19304
|
publishData(data_1) {
|
19091
19305
|
return __awaiter(this, arguments, void 0, function (data) {
|
19092
|
-
var
|
19306
|
+
var _this3 = this;
|
19093
19307
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
19094
19308
|
return function* () {
|
19095
19309
|
const kind = options.reliable ? DataPacket_Kind.RELIABLE : DataPacket_Kind.LOSSY;
|
@@ -19100,14 +19314,14 @@ class LocalParticipant extends Participant {
|
|
19100
19314
|
value: {
|
19101
19315
|
case: 'user',
|
19102
19316
|
value: new UserPacket({
|
19103
|
-
participantIdentity:
|
19317
|
+
participantIdentity: _this3.identity,
|
19104
19318
|
payload: data,
|
19105
19319
|
destinationIdentities,
|
19106
19320
|
topic
|
19107
19321
|
})
|
19108
19322
|
}
|
19109
19323
|
});
|
19110
|
-
yield
|
19324
|
+
yield _this3.engine.sendDataPacket(packet, kind);
|
19111
19325
|
}();
|
19112
19326
|
});
|
19113
19327
|
}
|
@@ -19762,7 +19976,10 @@ class Room extends eventsExports.EventEmitter {
|
|
19762
19976
|
// trigger the first fetch without waiting for a response
|
19763
19977
|
// if initial connection fails, this will speed up picking regional url
|
19764
19978
|
// on subsequent runs
|
19765
|
-
this.regionUrlProvider.fetchRegionSettings().
|
19979
|
+
this.regionUrlProvider.fetchRegionSettings().then(settings => {
|
19980
|
+
var _a;
|
19981
|
+
(_a = this.regionUrlProvider) === null || _a === void 0 ? void 0 : _a.setServerReportedRegions(settings);
|
19982
|
+
}).catch(e => {
|
19766
19983
|
this.log.warn('could not fetch region settings', Object.assign(Object.assign({}, this.logContext), {
|
19767
19984
|
error: e
|
19768
19985
|
}));
|
@@ -20332,6 +20549,9 @@ class Room extends eventsExports.EventEmitter {
|
|
20332
20549
|
this.onLocalParticipantNameChanged = name => {
|
20333
20550
|
this.emit(RoomEvent.ParticipantNameChanged, name, this.localParticipant);
|
20334
20551
|
};
|
20552
|
+
this.onLocalAttributesChanged = changedAttributes => {
|
20553
|
+
this.emit(RoomEvent.ParticipantAttributesChanged, changedAttributes, this.localParticipant);
|
20554
|
+
};
|
20335
20555
|
this.onLocalTrackMuted = pub => {
|
20336
20556
|
this.emit(RoomEvent.TrackMuted, pub, this.localParticipant);
|
20337
20557
|
};
|
@@ -20820,7 +21040,7 @@ class Room extends eventsExports.EventEmitter {
|
|
20820
21040
|
});
|
20821
21041
|
}
|
20822
21042
|
setupLocalParticipantEvents() {
|
20823
|
-
this.localParticipant.on(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).on(ParticipantEvent.ParticipantNameChanged, this.onLocalParticipantNameChanged).on(ParticipantEvent.TrackMuted, this.onLocalTrackMuted).on(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted).on(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished).on(ParticipantEvent.LocalTrackUnpublished, this.onLocalTrackUnpublished).on(ParticipantEvent.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).on(ParticipantEvent.MediaDevicesError, this.onMediaDevicesError).on(ParticipantEvent.AudioStreamAcquired, this.startAudio).on(ParticipantEvent.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged);
|
21043
|
+
this.localParticipant.on(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).on(ParticipantEvent.ParticipantNameChanged, this.onLocalParticipantNameChanged).on(ParticipantEvent.AttributesChanged, this.onLocalAttributesChanged).on(ParticipantEvent.TrackMuted, this.onLocalTrackMuted).on(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted).on(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished).on(ParticipantEvent.LocalTrackUnpublished, this.onLocalTrackUnpublished).on(ParticipantEvent.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).on(ParticipantEvent.MediaDevicesError, this.onMediaDevicesError).on(ParticipantEvent.AudioStreamAcquired, this.startAudio).on(ParticipantEvent.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged);
|
20824
21044
|
}
|
20825
21045
|
recreateEngine() {
|
20826
21046
|
var _a;
|
@@ -20913,7 +21133,7 @@ class Room extends eventsExports.EventEmitter {
|
|
20913
21133
|
(_b = pub.track) === null || _b === void 0 ? void 0 : _b.stop();
|
20914
21134
|
}
|
20915
21135
|
});
|
20916
|
-
this.localParticipant.off(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).off(ParticipantEvent.ParticipantNameChanged, this.onLocalParticipantNameChanged).off(ParticipantEvent.TrackMuted, this.onLocalTrackMuted).off(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted).off(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished).off(ParticipantEvent.LocalTrackUnpublished, this.onLocalTrackUnpublished).off(ParticipantEvent.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).off(ParticipantEvent.MediaDevicesError, this.onMediaDevicesError).off(ParticipantEvent.AudioStreamAcquired, this.startAudio).off(ParticipantEvent.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged);
|
21136
|
+
this.localParticipant.off(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged).off(ParticipantEvent.ParticipantNameChanged, this.onLocalParticipantNameChanged).off(ParticipantEvent.AttributesChanged, this.onLocalAttributesChanged).off(ParticipantEvent.TrackMuted, this.onLocalTrackMuted).off(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted).off(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished).off(ParticipantEvent.LocalTrackUnpublished, this.onLocalTrackUnpublished).off(ParticipantEvent.ConnectionQualityChanged, this.onLocalConnectionQualityChanged).off(ParticipantEvent.MediaDevicesError, this.onMediaDevicesError).off(ParticipantEvent.AudioStreamAcquired, this.startAudio).off(ParticipantEvent.ParticipantPermissionsChanged, this.onLocalParticipantPermissionsChanged);
|
20917
21137
|
this.localParticipant.trackPublications.clear();
|
20918
21138
|
this.localParticipant.videoTrackPublications.clear();
|
20919
21139
|
this.localParticipant.audioTrackPublications.clear();
|
@@ -21047,6 +21267,8 @@ class Room extends eventsExports.EventEmitter {
|
|
21047
21267
|
this.emitWhenConnected(RoomEvent.ParticipantMetadataChanged, metadata, participant);
|
21048
21268
|
}).on(ParticipantEvent.ParticipantNameChanged, name => {
|
21049
21269
|
this.emitWhenConnected(RoomEvent.ParticipantNameChanged, name, participant);
|
21270
|
+
}).on(ParticipantEvent.AttributesChanged, changedAttributes => {
|
21271
|
+
this.emitWhenConnected(RoomEvent.ParticipantAttributesChanged, changedAttributes, participant);
|
21050
21272
|
}).on(ParticipantEvent.ConnectionQualityChanged, quality => {
|
21051
21273
|
this.emitWhenConnected(RoomEvent.ConnectionQualityChanged, quality, participant);
|
21052
21274
|
}).on(ParticipantEvent.ParticipantPermissionsChanged, prevPermissions => {
|
@@ -21610,9 +21832,10 @@ class ReconnectCheck extends Checker {
|
|
21610
21832
|
setTimeout(resolve, 5000);
|
21611
21833
|
reconnectResolver = resolve;
|
21612
21834
|
});
|
21613
|
-
|
21835
|
+
const handleReconnecting = () => {
|
21614
21836
|
reconnectingTriggered = true;
|
21615
|
-
}
|
21837
|
+
};
|
21838
|
+
room.on(RoomEvent.SignalReconnecting, handleReconnecting).on(RoomEvent.Reconnecting, handleReconnecting).on(RoomEvent.Reconnected, () => {
|
21616
21839
|
reconnected = true;
|
21617
21840
|
reconnectResolver(true);
|
21618
21841
|
});
|
@@ -21940,5 +22163,5 @@ function isFacingModeValue(item) {
|
|
21940
22163
|
return item === undefined || allowedValues.includes(item);
|
21941
22164
|
}
|
21942
22165
|
|
21943
|
-
export { AudioPresets, BaseKeyProvider, CheckStatus, Checker, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, KeyHandlerEvent, KeyProviderEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, LoggerNames, MediaDeviceFailure, Mutex, NegotiationError, Participant, ParticipantEvent, ParticipantInfo_Kind as ParticipantKind, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, ScreenSharePresets, SubscriptionError, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, importKey, isBackupCodec, isBrowserSupported, isE2EESupported, isInsertableStreamSupported, isScriptTransformSupported, isVideoFrame, needsRbspUnescaping, parseRbsp, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs, writeRbsp };
|
22166
|
+
export { AudioPresets, BaseKeyProvider, CheckStatus, Checker, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, CriticalTimers, CryptorError, CryptorErrorReason, CryptorEvent, DataPacket_Kind, DefaultReconnectPolicy, DeviceUnsupportedError, DisconnectReason, EncryptionEvent, EngineEvent, ExternalE2EEKeyProvider, KeyHandlerEvent, KeyProviderEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, LoggerNames, MediaDeviceFailure, Mutex, NegotiationError, Participant, ParticipantEvent, ParticipantInfo_Kind as ParticipantKind, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, ScreenSharePresets, SignalRequestError, SubscriptionError, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createAudioAnalyser, createE2EEKey, createKeyMaterialFromBuffer, createKeyMaterialFromString, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, deriveKeys, detachTrack, facingModeFromDeviceLabel, facingModeFromLocalTrack, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, importKey, isBackupCodec, isBrowserSupported, isE2EESupported, isInsertableStreamSupported, isScriptTransformSupported, isVideoFrame, needsRbspUnescaping, parseRbsp, protocolVersion, ratchet, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, version, videoCodecs, writeRbsp };
|
21944
22167
|
//# sourceMappingURL=livekit-client.esm.mjs.map
|