@voxevolv/client 0.3.16 → 0.3.18
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/CHANGELOG.md +23 -0
- package/README.md +4 -0
- package/dist/browser/index.js +7 -7
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/index.js.sha384 +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/connection-diagnostics.d.ts +24 -0
- package/dist/connection-diagnostics.d.ts.map +1 -0
- package/dist/connection-diagnostics.js +155 -0
- package/dist/connection-diagnostics.js.map +1 -0
- package/dist/diagnostics.d.ts +16 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +28 -5
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -7
- package/dist/index.js.map +2 -2
- package/dist/presentations.d.ts +3 -1
- package/dist/presentations.d.ts.map +1 -1
- package/dist/presentations.js +35 -6
- package/dist/presentations.js.map +1 -1
- package/dist/vendor/livekit-client.esm.mjs +90 -9
- package/package.json +3 -3
package/dist/presentations.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ClientDiagnosticInput } from "./diagnostics.js";
|
|
1
2
|
type SendRpc = (request: {
|
|
2
3
|
destinationIdentity: string;
|
|
3
4
|
method: string;
|
|
@@ -9,8 +10,9 @@ export declare class Presentations {
|
|
|
9
10
|
private readonly send;
|
|
10
11
|
private readonly isClosed;
|
|
11
12
|
private readonly receiptFailed;
|
|
13
|
+
private readonly observe?;
|
|
12
14
|
private readonly results;
|
|
13
|
-
constructor(send: SendRpc, isClosed: () => boolean, receiptFailed: () => void);
|
|
15
|
+
constructor(send: SendRpc, isClosed: () => boolean, receiptFailed: () => void, observe?: ((entry: ClientDiagnosticInput) => void) | undefined);
|
|
14
16
|
invoke(id: string, worker: string, execute: () => Promise<string>): Promise<string>;
|
|
15
17
|
private execute;
|
|
16
18
|
private complete;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentations.d.ts","sourceRoot":"","sources":["../src/presentations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"presentations.d.ts","sourceRoot":"","sources":["../src/presentations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAM9D,KAAK,OAAO,GAAG,CAAC,OAAO,EAAE;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;CACzB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAItB,qFAAqF;AACrF,qBAAa,aAAa;IAItB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAN3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IAEjE,YACmB,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,OAAO,EACvB,aAAa,EAAE,MAAM,IAAI,EACzB,OAAO,CAAC,GAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,aAAA,EAC/D;IAEJ,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBlF;YAEa,OAAO;IAuCrB,OAAO,CAAC,QAAQ;YAQF,OAAO;CA+BtB"}
|
package/dist/presentations.js
CHANGED
|
@@ -7,11 +7,13 @@ export class Presentations {
|
|
|
7
7
|
send;
|
|
8
8
|
isClosed;
|
|
9
9
|
receiptFailed;
|
|
10
|
+
observe;
|
|
10
11
|
results = new Map();
|
|
11
|
-
constructor(send, isClosed, receiptFailed) {
|
|
12
|
+
constructor(send, isClosed, receiptFailed, observe) {
|
|
12
13
|
this.send = send;
|
|
13
14
|
this.isClosed = isClosed;
|
|
14
15
|
this.receiptFailed = receiptFailed;
|
|
16
|
+
this.observe = observe;
|
|
15
17
|
}
|
|
16
18
|
invoke(id, worker, execute) {
|
|
17
19
|
const key = JSON.stringify([worker, id]);
|
|
@@ -81,11 +83,38 @@ export class Presentations {
|
|
|
81
83
|
this.receiptFailed();
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
|
-
request(id, worker, payload) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
async request(id, worker, payload) {
|
|
87
|
+
const startedAt = performance.now();
|
|
88
|
+
const record = (entry) => {
|
|
89
|
+
try {
|
|
90
|
+
this.observe?.({
|
|
91
|
+
operation: "tool_rpc", status: "started", tool_name: "present_attachment",
|
|
92
|
+
presentation_id: id, timeout_ms: 2_000,
|
|
93
|
+
reason: payload.action === "claim" ? "presentation_claim" : "presentation_complete",
|
|
94
|
+
duration_ms: performance.now() - startedAt, ...entry,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Optional diagnostics must not change authorization or display behavior.
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
record({ stage: "publish_started" });
|
|
102
|
+
try {
|
|
103
|
+
const response = await this.send({
|
|
104
|
+
destinationIdentity: worker, method: PRESENTATION_METHOD,
|
|
105
|
+
payload: JSON.stringify({ operation_id: id, ...payload }), responseTimeout: 2_000,
|
|
106
|
+
});
|
|
107
|
+
record({ stage: "received", status: "succeeded" });
|
|
108
|
+
return response;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
// npm's patched transport and this module can load distinct RpcError
|
|
112
|
+
// classes. Read the numeric code without relying on constructor identity.
|
|
113
|
+
const rpcErrorCode = error && typeof error === "object" && "code" in error
|
|
114
|
+
&& typeof error.code === "number" ? error.code : undefined;
|
|
115
|
+
record({ status: "failed", rpc_error_code: rpcErrorCode });
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
89
118
|
}
|
|
90
119
|
}
|
|
91
120
|
//# sourceMappingURL=presentations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentations.js","sourceRoot":"","sources":["../src/presentations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"presentations.js","sourceRoot":"","sources":["../src/presentations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AACpD,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAWhC,qFAAqF;AACrF,MAAM,OAAO,aAAa;IAIL,IAAI;IACJ,QAAQ;IACR,aAAa;IACb,OAAO;IANT,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEjE,YACmB,IAAa,EACb,QAAuB,EACvB,aAAyB,EACzB,OAAgD;oBAHhD,IAAI;wBACJ,QAAQ;6BACR,aAAa;uBACb,OAAO;IACvB,CAAC;IAEJ,MAAM,CAAC,EAAU,EAAE,MAAc,EAAE,OAA8B;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC;QACvC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,wBAAwB,EAAE,CAAC;YAClD,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,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AQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;gBAC/B,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB;gBACxD,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,eAAe,EAAE,KAAK;aAClF,CAAC,CAAC;YACH,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;YACnD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qEAAqE;YACrE,0EAA0E;YAC1E,MAAM,YAAY,GAAG,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK;mBACrE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7D,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;YAC3D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -16249,6 +16249,7 @@ class WebSocketStream {
|
|
|
16249
16249
|
reason = _ref3.reason;
|
|
16250
16250
|
resolve({
|
|
16251
16251
|
closeCode: code,
|
|
16252
|
+
wasClean: _ref3.wasClean,
|
|
16252
16253
|
reason
|
|
16253
16254
|
});
|
|
16254
16255
|
ws.removeEventListener('error', rejectHandler);
|
|
@@ -16347,7 +16348,7 @@ class SignalClient {
|
|
|
16347
16348
|
}();
|
|
16348
16349
|
});
|
|
16349
16350
|
}
|
|
16350
|
-
reconnect(url, token, sid, reason) {
|
|
16351
|
+
reconnect(url, token, sid, reason, abortSignal) {
|
|
16351
16352
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16352
16353
|
if (!this.options) {
|
|
16353
16354
|
this.log.warn('attempted to reconnect without signal options being set, ignoring');
|
|
@@ -16360,7 +16361,7 @@ class SignalClient {
|
|
|
16360
16361
|
reconnect: true,
|
|
16361
16362
|
sid,
|
|
16362
16363
|
reconnectReason: reason
|
|
16363
|
-
}),
|
|
16364
|
+
}), abortSignal, this.useV0SignalPath);
|
|
16364
16365
|
return res;
|
|
16365
16366
|
});
|
|
16366
16367
|
}
|
|
@@ -16424,10 +16425,21 @@ class SignalClient {
|
|
|
16424
16425
|
reconnect: opts.reconnect,
|
|
16425
16426
|
reconnectReason: opts.reconnectReason
|
|
16426
16427
|
});
|
|
16428
|
+
if (abortSignal?.aborted) {
|
|
16429
|
+
yield abortHandler(abortSignal);
|
|
16430
|
+
return;
|
|
16431
|
+
}
|
|
16427
16432
|
this.ws = new WebSocketStream(rtcUrl);
|
|
16428
16433
|
try {
|
|
16429
16434
|
this.ws.closed.then(closeInfo => {
|
|
16430
16435
|
var _a;
|
|
16436
|
+
if (this.state === SignalConnectionState.CONNECTED) {
|
|
16437
|
+
try { this.voxevolvObserveConnection?.({
|
|
16438
|
+
reason: "websocket_closed",
|
|
16439
|
+
ws_close_code: closeInfo.closeCode ?? closeInfo.code,
|
|
16440
|
+
ws_close_clean: closeInfo.wasClean
|
|
16441
|
+
}); } catch {}
|
|
16442
|
+
}
|
|
16431
16443
|
if (this.isEstablishingConnection) {
|
|
16432
16444
|
reject(ConnectionError.internal("Websocket got closed during a (re)connection attempt: ".concat(closeInfo.reason)));
|
|
16433
16445
|
}
|
|
@@ -16444,6 +16456,7 @@ class SignalClient {
|
|
|
16444
16456
|
}
|
|
16445
16457
|
return;
|
|
16446
16458
|
}).catch(reason => {
|
|
16459
|
+
try { this.voxevolvObserveConnection?.({ reason: "websocket_error" }); } catch {}
|
|
16447
16460
|
if (this.isEstablishingConnection) {
|
|
16448
16461
|
reject(ConnectionError.internal("Websocket error during a (re)connection attempt: ".concat(reason)));
|
|
16449
16462
|
}
|
|
@@ -16462,6 +16475,10 @@ class SignalClient {
|
|
|
16462
16475
|
return;
|
|
16463
16476
|
}));
|
|
16464
16477
|
clearTimeout(wsTimeout);
|
|
16478
|
+
if (abortSignal?.aborted) {
|
|
16479
|
+
yield abortHandler(abortSignal);
|
|
16480
|
+
return;
|
|
16481
|
+
}
|
|
16465
16482
|
if (!connection) {
|
|
16466
16483
|
return;
|
|
16467
16484
|
}
|
|
@@ -16469,6 +16486,10 @@ class SignalClient {
|
|
|
16469
16486
|
this.streamWriter = connection.writable.getWriter();
|
|
16470
16487
|
const firstMessage = yield signalReader.read();
|
|
16471
16488
|
signalReader.releaseLock();
|
|
16489
|
+
if (abortSignal?.aborted) {
|
|
16490
|
+
yield abortHandler(abortSignal);
|
|
16491
|
+
return;
|
|
16492
|
+
}
|
|
16472
16493
|
if (!firstMessage.value) {
|
|
16473
16494
|
throw ConnectionError.internal('no message received as first message');
|
|
16474
16495
|
}
|
|
@@ -16918,6 +16939,11 @@ class SignalClient {
|
|
|
16918
16939
|
handleOnClose(reason) {
|
|
16919
16940
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16920
16941
|
if (this.state === SignalConnectionState.DISCONNECTED) return;
|
|
16942
|
+
try { this.voxevolvObserveConnection?.({
|
|
16943
|
+
reason: reason === "ping timeout" ? "signal_ping_timeout" : "signal_closed",
|
|
16944
|
+
signal_timeout_ms: this.pingTimeoutDuration * 1000,
|
|
16945
|
+
signal_idle_ms: this.voxevolvLastSignalAt === undefined ? undefined : performance.now() - this.voxevolvLastSignalAt
|
|
16946
|
+
}); } catch {}
|
|
16921
16947
|
const onCloseCallback = this.onClose;
|
|
16922
16948
|
yield this.close(undefined, reason);
|
|
16923
16949
|
this.log.info("websocket connection closed: ".concat(reason), {
|
|
@@ -16938,6 +16964,7 @@ class SignalClient {
|
|
|
16938
16964
|
* Call this after receiving a pong message
|
|
16939
16965
|
*/
|
|
16940
16966
|
resetPingTimeout() {
|
|
16967
|
+
this.voxevolvLastSignalAt = performance.now();
|
|
16941
16968
|
this.clearPingTimeout();
|
|
16942
16969
|
if (!this.pingTimeoutDuration) {
|
|
16943
16970
|
this.log.warn('ping timeout duration not set');
|
|
@@ -21078,6 +21105,38 @@ var DataChannelKind;
|
|
|
21078
21105
|
// `0` means "no limit".
|
|
21079
21106
|
const DEFAULT_MAX_MESSAGE_SIZE = 64000;
|
|
21080
21107
|
/** @internal */
|
|
21108
|
+
|
|
21109
|
+
function voxevolvAssertEngineOpen(engine) {
|
|
21110
|
+
if (engine.voxevolvCloseController.signal.aborted) {
|
|
21111
|
+
throw new UnexpectedConnectionState('Engine was discarded');
|
|
21112
|
+
}
|
|
21113
|
+
}
|
|
21114
|
+
|
|
21115
|
+
async function voxevolvUntilEngineClosed(engine, callerSignal, operation) {
|
|
21116
|
+
voxevolvAssertEngineOpen(engine);
|
|
21117
|
+
if (callerSignal?.aborted) throw ConnectionError.cancelled('Connection aborted');
|
|
21118
|
+
const lifetime = engine.voxevolvCloseController.signal;
|
|
21119
|
+
const controller = new AbortController();
|
|
21120
|
+
let cancel;
|
|
21121
|
+
const cancelled = new Promise((_, reject) => {
|
|
21122
|
+
cancel = () => {
|
|
21123
|
+
controller.abort();
|
|
21124
|
+
reject(lifetime.aborted
|
|
21125
|
+
? new UnexpectedConnectionState('Engine was discarded')
|
|
21126
|
+
: ConnectionError.cancelled('Connection aborted'));
|
|
21127
|
+
};
|
|
21128
|
+
lifetime.addEventListener('abort', cancel, { once: true });
|
|
21129
|
+
callerSignal?.addEventListener('abort', cancel, { once: true });
|
|
21130
|
+
});
|
|
21131
|
+
try {
|
|
21132
|
+
// Abort the transport and stop waiting even if it returns a late response.
|
|
21133
|
+
return await Promise.race([operation(controller.signal), cancelled]);
|
|
21134
|
+
} finally {
|
|
21135
|
+
lifetime.removeEventListener('abort', cancel);
|
|
21136
|
+
callerSignal?.removeEventListener('abort', cancel);
|
|
21137
|
+
}
|
|
21138
|
+
}
|
|
21139
|
+
|
|
21081
21140
|
class RTCEngine extends eventsExports.EventEmitter {
|
|
21082
21141
|
get isClosed() {
|
|
21083
21142
|
return this._isClosed;
|
|
@@ -21103,6 +21162,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21103
21162
|
this.pcState = PCState.New;
|
|
21104
21163
|
this._isClosed = true;
|
|
21105
21164
|
this._isNewlyCreated = true;
|
|
21165
|
+
this.voxevolvCloseController = new AbortController();
|
|
21106
21166
|
this.pendingTrackResolvers = {};
|
|
21107
21167
|
this.reconnectAttempts = 0;
|
|
21108
21168
|
this.reconnectStart = 0;
|
|
@@ -21259,9 +21319,12 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21259
21319
|
// continues to work, we can reconnect to websocket to continue the session
|
|
21260
21320
|
// after a number of retries, we'll close and give up permanently
|
|
21261
21321
|
this.handleDisconnect = (connection, disconnectReason) => {
|
|
21262
|
-
if (this._isClosed) {
|
|
21322
|
+
if (this._isClosed || this.voxevolvCloseController.signal.aborted) {
|
|
21263
21323
|
return;
|
|
21264
21324
|
}
|
|
21325
|
+
try { this.voxevolvObserveConnection?.({
|
|
21326
|
+
reason: "livekit_reconnect_requested", reconnect_reason: disconnectReason ?? 0
|
|
21327
|
+
}); } catch {}
|
|
21265
21328
|
this.log.warn("".concat(connection, " disconnected"));
|
|
21266
21329
|
if (this.reconnectAttempts === 0) {
|
|
21267
21330
|
// only reset start time on the first try
|
|
@@ -21423,6 +21486,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21423
21486
|
let useV0Path = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
21424
21487
|
return function* () {
|
|
21425
21488
|
var _a, _b, _c;
|
|
21489
|
+
voxevolvAssertEngineOpen(_this2);
|
|
21426
21490
|
_this2._isNewlyCreated = false;
|
|
21427
21491
|
_this2.url = url;
|
|
21428
21492
|
_this2.token = token;
|
|
@@ -21444,6 +21508,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21444
21508
|
// createInitialOffer() defers setLocalDescription (via pendingInitialOffer) until the
|
|
21445
21509
|
// answer is applied, after updateConfiguration() has set the server's TURN servers.
|
|
21446
21510
|
yield _this2.configure();
|
|
21511
|
+
voxevolvAssertEngineOpen(_this2);
|
|
21447
21512
|
_this2.applyInitialPublisherLayout();
|
|
21448
21513
|
}
|
|
21449
21514
|
const offer = yield (_a = _this2.pcManager) === null || _a === void 0 ? void 0 : _a.publisher.createInitialOffer();
|
|
@@ -21458,7 +21523,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21458
21523
|
_this2.shouldFailOnV1Path = false;
|
|
21459
21524
|
throw ConnectionError.serviceNotFound('Simulated v1 path failure', 'v0-rtc');
|
|
21460
21525
|
}
|
|
21461
|
-
const joinResponse = yield _this2
|
|
21526
|
+
const joinResponse = yield voxevolvUntilEngineClosed(_this2, abortSignal,
|
|
21527
|
+
signal => _this2.client.join(url, token, opts, signal, useV0Path, offerProto));
|
|
21528
|
+
voxevolvAssertEngineOpen(_this2);
|
|
21462
21529
|
_this2._isClosed = false;
|
|
21463
21530
|
_this2.latestJoinResponse = joinResponse;
|
|
21464
21531
|
_this2.participantSid = (_b = joinResponse.participant) === null || _b === void 0 ? void 0 : _b.sid;
|
|
@@ -21471,6 +21538,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21471
21538
|
// the server's ICE servers and topology, then negotiate separately rather than bundling
|
|
21472
21539
|
// the offer with the join.
|
|
21473
21540
|
yield _this2.configure(joinResponse, !useV0Path);
|
|
21541
|
+
voxevolvAssertEngineOpen(_this2);
|
|
21474
21542
|
if (!useV0Path) {
|
|
21475
21543
|
// The V1 first offer must carry the media layout so Firefox binds receive decoders for
|
|
21476
21544
|
// subscribed tracks — without it, subscribed audio/video arrive as RTP but
|
|
@@ -21485,6 +21553,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21485
21553
|
});
|
|
21486
21554
|
}
|
|
21487
21555
|
}
|
|
21556
|
+
voxevolvAssertEngineOpen(_this2);
|
|
21488
21557
|
_this2.registerOnLineListener();
|
|
21489
21558
|
_this2.clientConfiguration = joinResponse.clientConfiguration;
|
|
21490
21559
|
_this2.emit(EngineEvent.SignalConnected, joinResponse);
|
|
@@ -21527,9 +21596,12 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
21527
21596
|
});
|
|
21528
21597
|
}
|
|
21529
21598
|
close() {
|
|
21599
|
+
const alreadyClosing = this.voxevolvCloseController.signal.aborted;
|
|
21600
|
+
// Discard synchronously, before cleanup waits for its lock.
|
|
21601
|
+
this.voxevolvCloseController.abort();
|
|
21530
21602
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21531
21603
|
const unlock = yield this.closingLock.lock();
|
|
21532
|
-
if (this.isClosed) {
|
|
21604
|
+
if (this.isClosed && alreadyClosing) {
|
|
21533
21605
|
unlock();
|
|
21534
21606
|
return;
|
|
21535
21607
|
}
|
|
@@ -22115,7 +22187,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
22115
22187
|
attemptReconnect(reason) {
|
|
22116
22188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22117
22189
|
var _a, _b, _c;
|
|
22118
|
-
if (this._isClosed) {
|
|
22190
|
+
if (this._isClosed || this.voxevolvCloseController.signal.aborted) {
|
|
22119
22191
|
return;
|
|
22120
22192
|
}
|
|
22121
22193
|
// guard for attempting reconnection multiple times while one attempt is still not finished
|
|
@@ -22189,6 +22261,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
22189
22261
|
}
|
|
22190
22262
|
yield this.cleanupPeerConnections();
|
|
22191
22263
|
yield this.cleanupClient();
|
|
22264
|
+
voxevolvAssertEngineOpen(this);
|
|
22192
22265
|
let joinResponse;
|
|
22193
22266
|
try {
|
|
22194
22267
|
if (!this.signalOpts) {
|
|
@@ -22207,9 +22280,11 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
22207
22280
|
this.shouldFailNext = false;
|
|
22208
22281
|
throw new Error('simulated failure');
|
|
22209
22282
|
}
|
|
22283
|
+
voxevolvAssertEngineOpen(this);
|
|
22210
22284
|
this.client.setReconnected();
|
|
22211
22285
|
this.emit(EngineEvent.SignalRestarted, joinResponse);
|
|
22212
|
-
yield this.waitForPCReconnected();
|
|
22286
|
+
yield voxevolvUntilEngineClosed(this, undefined, () => this.waitForPCReconnected());
|
|
22287
|
+
voxevolvAssertEngineOpen(this);
|
|
22213
22288
|
// re-check signal connection state before setting engine as resumed
|
|
22214
22289
|
if (this.client.currentState !== SignalConnectionState.CONNECTED) {
|
|
22215
22290
|
throw new SignalReconnectError('Signal connection got severed during reconnect');
|
|
@@ -22218,7 +22293,9 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
22218
22293
|
// reconnect success
|
|
22219
22294
|
this.emit(EngineEvent.Restarted);
|
|
22220
22295
|
} catch (error) {
|
|
22296
|
+
voxevolvAssertEngineOpen(this);
|
|
22221
22297
|
const nextRegionUrl = yield (_b = this.regionStrategy) === null || _b === void 0 ? void 0 : _b.getNextUrl();
|
|
22298
|
+
voxevolvAssertEngineOpen(this);
|
|
22222
22299
|
if (nextRegionUrl) {
|
|
22223
22300
|
yield this.restartConnection(nextRegionUrl);
|
|
22224
22301
|
return;
|
|
@@ -22246,7 +22323,8 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
22246
22323
|
let res;
|
|
22247
22324
|
try {
|
|
22248
22325
|
this.setupSignalClientCallbacks();
|
|
22249
|
-
res = yield
|
|
22326
|
+
res = yield voxevolvUntilEngineClosed(this, undefined,
|
|
22327
|
+
signal => this.client.reconnect(this.url, this.token, this.participantSid, reason, signal));
|
|
22250
22328
|
} catch (error) {
|
|
22251
22329
|
let message = '';
|
|
22252
22330
|
if (error instanceof Error) {
|
|
@@ -22263,6 +22341,7 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
22263
22341
|
}
|
|
22264
22342
|
throw new SignalReconnectError(message);
|
|
22265
22343
|
}
|
|
22344
|
+
voxevolvAssertEngineOpen(this);
|
|
22266
22345
|
this.emit(EngineEvent.SignalResumed);
|
|
22267
22346
|
if (res) {
|
|
22268
22347
|
const rtcConfig = this.makeRTCConfiguration(res);
|
|
@@ -22278,7 +22357,8 @@ class RTCEngine extends eventsExports.EventEmitter {
|
|
|
22278
22357
|
throw new Error('simulated failure');
|
|
22279
22358
|
}
|
|
22280
22359
|
yield this.pcManager.triggerIceRestart();
|
|
22281
|
-
yield this.waitForPCReconnected();
|
|
22360
|
+
yield voxevolvUntilEngineClosed(this, undefined, () => this.waitForPCReconnected());
|
|
22361
|
+
voxevolvAssertEngineOpen(this);
|
|
22282
22362
|
// re-check signal connection state before setting engine as resumed
|
|
22283
22363
|
if (this.client.currentState !== SignalConnectionState.CONNECTED) {
|
|
22284
22364
|
throw new SignalReconnectError('Signal connection got severed during reconnect');
|
|
@@ -30817,6 +30897,7 @@ class Room extends eventsExports.EventEmitter {
|
|
|
30817
30897
|
}
|
|
30818
30898
|
this.engine = new RTCEngine(this.options);
|
|
30819
30899
|
this.engine.e2eeManager = this.e2eeManager;
|
|
30900
|
+
try { this.voxevolvObserveEngine?.(); } catch {}
|
|
30820
30901
|
this.engine.on(EngineEvent.ParticipantUpdate, this.handleParticipantUpdates).on(EngineEvent.RoomUpdate, this.handleRoomUpdate).on(EngineEvent.SpeakersChanged, this.handleSpeakersChanged).on(EngineEvent.StreamStateChanged, this.handleStreamStateUpdate).on(EngineEvent.ConnectionQualityUpdate, this.handleConnectionQualityUpdate).on(EngineEvent.SubscriptionError, this.handleSubscriptionError).on(EngineEvent.SubscriptionPermissionUpdate, this.handleSubscriptionPermissionUpdate).on(EngineEvent.MediaTrackAdded, (mediaTrack, stream, receiver) => {
|
|
30821
30902
|
this.onTrackAdded(mediaTrack, stream, receiver);
|
|
30822
30903
|
}).on(EngineEvent.Disconnected, reason => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voxevolv/client",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"description": "Browser SDK for VoxEvolv multimodal realtime sessions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsc -p tsconfig.json && node scripts/build-browser.mjs",
|
|
44
44
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
45
|
-
"test": "npm run build && node scripts/protocol-smoke.mjs && node --test scripts/context-delivery.test.mjs scripts/context-cancellation.test.mjs scripts/diagnostic-delivery.test.mjs scripts/presentations.test.mjs scripts/startup-recovery.test.mjs scripts/connection-lifecycle.test.mjs scripts/audio-recovery.test.mjs scripts/recovery-progress.test.mjs scripts/reliable-sequence.test.mjs && node scripts/transcript-smoke.mjs",
|
|
45
|
+
"test": "npm run build && node scripts/protocol-smoke.mjs && node --test scripts/context-delivery.test.mjs scripts/context-cancellation.test.mjs scripts/diagnostic-delivery.test.mjs scripts/connection-diagnostics.test.mjs scripts/presentations.test.mjs scripts/startup-recovery.test.mjs scripts/reconnect-cancellation.test.mjs scripts/connection-lifecycle.test.mjs scripts/audio-recovery.test.mjs scripts/recovery-progress.test.mjs scripts/reliable-sequence.test.mjs && node scripts/transcript-smoke.mjs",
|
|
46
46
|
"pack:check": "npm run build && npm pack --dry-run"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"livekit-client": "2.20.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"esbuild": "0.
|
|
52
|
+
"esbuild": "0.28.2",
|
|
53
53
|
"typescript": "7.0.2"
|
|
54
54
|
}
|
|
55
55
|
}
|