@whereby.com/media 11.3.5 → 11.4.0
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/index.cjs +28 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +28 -4
- package/dist/legacy-esm.js +28 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -67,6 +67,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
67
67
|
var _a$6;
|
|
68
68
|
(_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
|
|
69
69
|
const RTCSTATS_PROTOCOL_VERSION = "1.0";
|
|
70
|
+
const POLICY_VIOLATION = 1008;
|
|
70
71
|
const GETSTATS_BUFFER_SIZE = 20;
|
|
71
72
|
const clientInfo = {
|
|
72
73
|
id: uuid.v4(),
|
|
@@ -74,6 +75,13 @@ const clientInfo = {
|
|
|
74
75
|
};
|
|
75
76
|
const noop = () => { };
|
|
76
77
|
let resetDelta = noop;
|
|
78
|
+
let roomUrl = null;
|
|
79
|
+
function getConnectionPath() {
|
|
80
|
+
return roomUrl ? "/" : window.location.pathname;
|
|
81
|
+
}
|
|
82
|
+
function getConnectionQuery() {
|
|
83
|
+
return roomUrl ? `?roomUrl=${encodeURIComponent(roomUrl)}` : "";
|
|
84
|
+
}
|
|
77
85
|
function rtcStatsConnection(wsURL, logger = console) {
|
|
78
86
|
const buffer = [];
|
|
79
87
|
let ws;
|
|
@@ -84,6 +92,7 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
84
92
|
let roomSessionId;
|
|
85
93
|
let connectionShouldBeOpen;
|
|
86
94
|
let connectionAttempt = 0;
|
|
95
|
+
let reconnectTimeout;
|
|
87
96
|
let hasPassedOnRoomSessionId = false;
|
|
88
97
|
let getStatsBufferUsed = 0;
|
|
89
98
|
let deviceId;
|
|
@@ -149,8 +158,9 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
149
158
|
else {
|
|
150
159
|
buffer.push(args);
|
|
151
160
|
}
|
|
152
|
-
if ((ws === null || ws === void 0 ? void 0 : ws.readyState) === WebSocket.CLOSED && connectionShouldBeOpen) {
|
|
153
|
-
setTimeout(() => {
|
|
161
|
+
if ((ws === null || ws === void 0 ? void 0 : ws.readyState) === WebSocket.CLOSED && connectionShouldBeOpen && !reconnectTimeout) {
|
|
162
|
+
reconnectTimeout = setTimeout(() => {
|
|
163
|
+
reconnectTimeout = undefined;
|
|
154
164
|
if (ws.readyState === WebSocket.CLOSED && connectionShouldBeOpen) {
|
|
155
165
|
connection.connect();
|
|
156
166
|
}
|
|
@@ -159,22 +169,33 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
159
169
|
},
|
|
160
170
|
close: () => {
|
|
161
171
|
connectionShouldBeOpen = false;
|
|
172
|
+
clearTimeout(reconnectTimeout);
|
|
173
|
+
reconnectTimeout = undefined;
|
|
162
174
|
ws === null || ws === void 0 ? void 0 : ws.close();
|
|
163
175
|
},
|
|
164
176
|
connect: () => {
|
|
177
|
+
clearTimeout(reconnectTimeout);
|
|
178
|
+
reconnectTimeout = undefined;
|
|
165
179
|
connectionShouldBeOpen = true;
|
|
166
180
|
connectionAttempt += 1;
|
|
167
181
|
ws === null || ws === void 0 ? void 0 : ws.close();
|
|
168
182
|
connection.connected = true;
|
|
169
183
|
connection.attemptedConnectedAtLeastOnce = true;
|
|
170
|
-
|
|
184
|
+
const socket = new WebSocket(wsURL + getConnectionPath() + getConnectionQuery(), RTCSTATS_PROTOCOL_VERSION);
|
|
185
|
+
ws = socket;
|
|
171
186
|
ws.onerror = (e) => {
|
|
172
187
|
connection.connected = false;
|
|
173
188
|
logger.warn(`[RTCSTATS] WebSocket error`, e);
|
|
174
189
|
};
|
|
175
190
|
ws.onclose = (e) => {
|
|
176
191
|
connection.connected = false;
|
|
177
|
-
|
|
192
|
+
if (e.code === POLICY_VIOLATION && ws === socket) {
|
|
193
|
+
connectionShouldBeOpen = false;
|
|
194
|
+
logger.warn(`[RTCSTATS] Rejected by the server: ${e.reason}`);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
logger.info(`[RTCSTATS] Closed ${e.code}`);
|
|
198
|
+
}
|
|
178
199
|
resetDelta();
|
|
179
200
|
};
|
|
180
201
|
ws.onopen = () => {
|
|
@@ -247,6 +268,9 @@ const rtcStats = {
|
|
|
247
268
|
});
|
|
248
269
|
},
|
|
249
270
|
server,
|
|
271
|
+
setRoomUrl: (url) => {
|
|
272
|
+
roomUrl = url;
|
|
273
|
+
},
|
|
250
274
|
};
|
|
251
275
|
|
|
252
276
|
const debugOn = (typeof window !== "undefined" && new URLSearchParams(window.location.search).has("debug"));
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -47,6 +47,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
47
47
|
var _a$6;
|
|
48
48
|
(_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
|
|
49
49
|
const RTCSTATS_PROTOCOL_VERSION = "1.0";
|
|
50
|
+
const POLICY_VIOLATION = 1008;
|
|
50
51
|
const GETSTATS_BUFFER_SIZE = 20;
|
|
51
52
|
const clientInfo = {
|
|
52
53
|
id: v4$1(),
|
|
@@ -54,6 +55,13 @@ const clientInfo = {
|
|
|
54
55
|
};
|
|
55
56
|
const noop = () => { };
|
|
56
57
|
let resetDelta = noop;
|
|
58
|
+
let roomUrl = null;
|
|
59
|
+
function getConnectionPath() {
|
|
60
|
+
return roomUrl ? "/" : window.location.pathname;
|
|
61
|
+
}
|
|
62
|
+
function getConnectionQuery() {
|
|
63
|
+
return roomUrl ? `?roomUrl=${encodeURIComponent(roomUrl)}` : "";
|
|
64
|
+
}
|
|
57
65
|
function rtcStatsConnection(wsURL, logger = console) {
|
|
58
66
|
const buffer = [];
|
|
59
67
|
let ws;
|
|
@@ -64,6 +72,7 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
64
72
|
let roomSessionId;
|
|
65
73
|
let connectionShouldBeOpen;
|
|
66
74
|
let connectionAttempt = 0;
|
|
75
|
+
let reconnectTimeout;
|
|
67
76
|
let hasPassedOnRoomSessionId = false;
|
|
68
77
|
let getStatsBufferUsed = 0;
|
|
69
78
|
let deviceId;
|
|
@@ -129,8 +138,9 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
129
138
|
else {
|
|
130
139
|
buffer.push(args);
|
|
131
140
|
}
|
|
132
|
-
if ((ws === null || ws === void 0 ? void 0 : ws.readyState) === WebSocket.CLOSED && connectionShouldBeOpen) {
|
|
133
|
-
setTimeout(() => {
|
|
141
|
+
if ((ws === null || ws === void 0 ? void 0 : ws.readyState) === WebSocket.CLOSED && connectionShouldBeOpen && !reconnectTimeout) {
|
|
142
|
+
reconnectTimeout = setTimeout(() => {
|
|
143
|
+
reconnectTimeout = undefined;
|
|
134
144
|
if (ws.readyState === WebSocket.CLOSED && connectionShouldBeOpen) {
|
|
135
145
|
connection.connect();
|
|
136
146
|
}
|
|
@@ -139,22 +149,33 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
139
149
|
},
|
|
140
150
|
close: () => {
|
|
141
151
|
connectionShouldBeOpen = false;
|
|
152
|
+
clearTimeout(reconnectTimeout);
|
|
153
|
+
reconnectTimeout = undefined;
|
|
142
154
|
ws === null || ws === void 0 ? void 0 : ws.close();
|
|
143
155
|
},
|
|
144
156
|
connect: () => {
|
|
157
|
+
clearTimeout(reconnectTimeout);
|
|
158
|
+
reconnectTimeout = undefined;
|
|
145
159
|
connectionShouldBeOpen = true;
|
|
146
160
|
connectionAttempt += 1;
|
|
147
161
|
ws === null || ws === void 0 ? void 0 : ws.close();
|
|
148
162
|
connection.connected = true;
|
|
149
163
|
connection.attemptedConnectedAtLeastOnce = true;
|
|
150
|
-
|
|
164
|
+
const socket = new WebSocket(wsURL + getConnectionPath() + getConnectionQuery(), RTCSTATS_PROTOCOL_VERSION);
|
|
165
|
+
ws = socket;
|
|
151
166
|
ws.onerror = (e) => {
|
|
152
167
|
connection.connected = false;
|
|
153
168
|
logger.warn(`[RTCSTATS] WebSocket error`, e);
|
|
154
169
|
};
|
|
155
170
|
ws.onclose = (e) => {
|
|
156
171
|
connection.connected = false;
|
|
157
|
-
|
|
172
|
+
if (e.code === POLICY_VIOLATION && ws === socket) {
|
|
173
|
+
connectionShouldBeOpen = false;
|
|
174
|
+
logger.warn(`[RTCSTATS] Rejected by the server: ${e.reason}`);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
logger.info(`[RTCSTATS] Closed ${e.code}`);
|
|
178
|
+
}
|
|
158
179
|
resetDelta();
|
|
159
180
|
};
|
|
160
181
|
ws.onopen = () => {
|
|
@@ -227,6 +248,9 @@ const rtcStats = {
|
|
|
227
248
|
});
|
|
228
249
|
},
|
|
229
250
|
server,
|
|
251
|
+
setRoomUrl: (url) => {
|
|
252
|
+
roomUrl = url;
|
|
253
|
+
},
|
|
230
254
|
};
|
|
231
255
|
|
|
232
256
|
const debugOn = (typeof window !== "undefined" && new URLSearchParams(window.location.search).has("debug"));
|
package/dist/legacy-esm.js
CHANGED
|
@@ -47,6 +47,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
47
47
|
var _a$6;
|
|
48
48
|
(_a$6 = adapterRaw.default) !== null && _a$6 !== void 0 ? _a$6 : adapterRaw;
|
|
49
49
|
const RTCSTATS_PROTOCOL_VERSION = "1.0";
|
|
50
|
+
const POLICY_VIOLATION = 1008;
|
|
50
51
|
const GETSTATS_BUFFER_SIZE = 20;
|
|
51
52
|
const clientInfo = {
|
|
52
53
|
id: v4$1(),
|
|
@@ -54,6 +55,13 @@ const clientInfo = {
|
|
|
54
55
|
};
|
|
55
56
|
const noop = () => { };
|
|
56
57
|
let resetDelta = noop;
|
|
58
|
+
let roomUrl = null;
|
|
59
|
+
function getConnectionPath() {
|
|
60
|
+
return roomUrl ? "/" : window.location.pathname;
|
|
61
|
+
}
|
|
62
|
+
function getConnectionQuery() {
|
|
63
|
+
return roomUrl ? `?roomUrl=${encodeURIComponent(roomUrl)}` : "";
|
|
64
|
+
}
|
|
57
65
|
function rtcStatsConnection(wsURL, logger = console) {
|
|
58
66
|
const buffer = [];
|
|
59
67
|
let ws;
|
|
@@ -64,6 +72,7 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
64
72
|
let roomSessionId;
|
|
65
73
|
let connectionShouldBeOpen;
|
|
66
74
|
let connectionAttempt = 0;
|
|
75
|
+
let reconnectTimeout;
|
|
67
76
|
let hasPassedOnRoomSessionId = false;
|
|
68
77
|
let getStatsBufferUsed = 0;
|
|
69
78
|
let deviceId;
|
|
@@ -129,8 +138,9 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
129
138
|
else {
|
|
130
139
|
buffer.push(args);
|
|
131
140
|
}
|
|
132
|
-
if ((ws === null || ws === void 0 ? void 0 : ws.readyState) === WebSocket.CLOSED && connectionShouldBeOpen) {
|
|
133
|
-
setTimeout(() => {
|
|
141
|
+
if ((ws === null || ws === void 0 ? void 0 : ws.readyState) === WebSocket.CLOSED && connectionShouldBeOpen && !reconnectTimeout) {
|
|
142
|
+
reconnectTimeout = setTimeout(() => {
|
|
143
|
+
reconnectTimeout = undefined;
|
|
134
144
|
if (ws.readyState === WebSocket.CLOSED && connectionShouldBeOpen) {
|
|
135
145
|
connection.connect();
|
|
136
146
|
}
|
|
@@ -139,22 +149,33 @@ function rtcStatsConnection(wsURL, logger = console) {
|
|
|
139
149
|
},
|
|
140
150
|
close: () => {
|
|
141
151
|
connectionShouldBeOpen = false;
|
|
152
|
+
clearTimeout(reconnectTimeout);
|
|
153
|
+
reconnectTimeout = undefined;
|
|
142
154
|
ws === null || ws === void 0 ? void 0 : ws.close();
|
|
143
155
|
},
|
|
144
156
|
connect: () => {
|
|
157
|
+
clearTimeout(reconnectTimeout);
|
|
158
|
+
reconnectTimeout = undefined;
|
|
145
159
|
connectionShouldBeOpen = true;
|
|
146
160
|
connectionAttempt += 1;
|
|
147
161
|
ws === null || ws === void 0 ? void 0 : ws.close();
|
|
148
162
|
connection.connected = true;
|
|
149
163
|
connection.attemptedConnectedAtLeastOnce = true;
|
|
150
|
-
|
|
164
|
+
const socket = new WebSocket(wsURL + getConnectionPath() + getConnectionQuery(), RTCSTATS_PROTOCOL_VERSION);
|
|
165
|
+
ws = socket;
|
|
151
166
|
ws.onerror = (e) => {
|
|
152
167
|
connection.connected = false;
|
|
153
168
|
logger.warn(`[RTCSTATS] WebSocket error`, e);
|
|
154
169
|
};
|
|
155
170
|
ws.onclose = (e) => {
|
|
156
171
|
connection.connected = false;
|
|
157
|
-
|
|
172
|
+
if (e.code === POLICY_VIOLATION && ws === socket) {
|
|
173
|
+
connectionShouldBeOpen = false;
|
|
174
|
+
logger.warn(`[RTCSTATS] Rejected by the server: ${e.reason}`);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
logger.info(`[RTCSTATS] Closed ${e.code}`);
|
|
178
|
+
}
|
|
158
179
|
resetDelta();
|
|
159
180
|
};
|
|
160
181
|
ws.onopen = () => {
|
|
@@ -227,6 +248,9 @@ const rtcStats = {
|
|
|
227
248
|
});
|
|
228
249
|
},
|
|
229
250
|
server,
|
|
251
|
+
setRoomUrl: (url) => {
|
|
252
|
+
roomUrl = url;
|
|
253
|
+
},
|
|
230
254
|
};
|
|
231
255
|
|
|
232
256
|
const debugOn = (typeof window !== "undefined" && new URLSearchParams(window.location.search).has("debug"));
|