@whereby.com/media 9.3.0 → 9.3.1

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 CHANGED
@@ -221,9 +221,22 @@ function rtcStatsConnection(wsURL, logger = console) {
221
221
  return connection;
222
222
  }
223
223
  const RTCSTATS_URL = "wss://rtcstats.srv.whereby.com";
224
- const server = rtcStatsConnection(RTCSTATS_URL);
225
- const stats = rtcstats(server.trace, 10000, [""]);
226
- resetDelta = (stats === null || stats === void 0 ? void 0 : stats.resetDelta) || noop;
224
+ const noopServer = {
225
+ connected: false,
226
+ attemptedConnectedAtLeastOnce: false,
227
+ trace: noop,
228
+ close: noop,
229
+ connect: noop,
230
+ };
231
+ let server;
232
+ if (typeof window !== "undefined") {
233
+ server = rtcStatsConnection(RTCSTATS_URL);
234
+ const stats = rtcstats(server.trace, 10000, [""]);
235
+ resetDelta = (stats === null || stats === void 0 ? void 0 : stats.resetDelta) || noop;
236
+ }
237
+ else {
238
+ server = noopServer;
239
+ }
227
240
  const rtcStats = {
228
241
  sendEvent: (type, value) => {
229
242
  server.trace("customEvent", null, {
@@ -240,7 +253,7 @@ const rtcStats = {
240
253
  server,
241
254
  };
242
255
 
243
- const debugOn = new URLSearchParams(window.location.search).has("debug");
256
+ const debugOn = (typeof window !== "undefined" && new URLSearchParams(window.location.search).has("debug"));
244
257
  class Logger {
245
258
  constructor() {
246
259
  this._isEnabled = false;
@@ -1473,7 +1486,7 @@ const peerConnectionData = new WeakMap();
1473
1486
  const removePeerConnection = (pc) => {
1474
1487
  peerConnections = peerConnections.filter((old) => old !== pc);
1475
1488
  };
1476
- if (window.RTCPeerConnection) {
1489
+ if (typeof window !== "undefined" && window.RTCPeerConnection) {
1477
1490
  const OriginalRTCPeerConnection = window.RTCPeerConnection;
1478
1491
  function PatchedRTCPeerConnection(rtcConfig) {
1479
1492
  const pc = new OriginalRTCPeerConnection(rtcConfig);
@@ -2431,7 +2444,7 @@ function fromLocation({ host = "whereby.com", protocol = "https:" } = {}) {
2431
2444
  subdomain,
2432
2445
  };
2433
2446
  }
2434
- fromLocation(window && window.location);
2447
+ fromLocation(typeof window !== "undefined" ? window.location : undefined);
2435
2448
 
2436
2449
  var _a$2, _b$1;
2437
2450
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
@@ -7168,7 +7181,7 @@ class BandwidthTester extends EventEmitter {
7168
7181
  }
7169
7182
 
7170
7183
  const logger = new Logger();
7171
- const isMobile = /mobi/i.test(navigator.userAgent);
7184
+ const isMobile = typeof navigator !== "undefined" && /mobi/i.test(navigator.userAgent);
7172
7185
  class NoDevicesError extends Error {
7173
7186
  constructor(...args) {
7174
7187
  super(...args);
@@ -7426,8 +7439,8 @@ function hasGetDisplayMedia() {
7426
7439
  }
7427
7440
  const defaultDisplayMediaConstraints = {
7428
7441
  video: {
7429
- width: { max: window.screen.width },
7430
- height: { max: window.screen.height },
7442
+ width: { max: typeof window !== "undefined" ? window.screen.width : 0 },
7443
+ height: { max: typeof window !== "undefined" ? window.screen.height : 0 },
7431
7444
  },
7432
7445
  };
7433
7446
  function getDisplayMedia(constraints = defaultDisplayMediaConstraints, contentHint = "detail") {
package/dist/index.d.cts CHANGED
@@ -1759,6 +1759,12 @@ declare const rtcStats: {
1759
1759
  trace: (...args: any) => void;
1760
1760
  close: () => void;
1761
1761
  connect: () => void;
1762
+ } | {
1763
+ connected: boolean;
1764
+ attemptedConnectedAtLeastOnce: boolean;
1765
+ trace: () => void;
1766
+ close: () => void;
1767
+ connect: () => void;
1762
1768
  };
1763
1769
  };
1764
1770
 
package/dist/index.d.mts CHANGED
@@ -1759,6 +1759,12 @@ declare const rtcStats: {
1759
1759
  trace: (...args: any) => void;
1760
1760
  close: () => void;
1761
1761
  connect: () => void;
1762
+ } | {
1763
+ connected: boolean;
1764
+ attemptedConnectedAtLeastOnce: boolean;
1765
+ trace: () => void;
1766
+ close: () => void;
1767
+ connect: () => void;
1762
1768
  };
1763
1769
  };
1764
1770
 
package/dist/index.d.ts CHANGED
@@ -1759,6 +1759,12 @@ declare const rtcStats: {
1759
1759
  trace: (...args: any) => void;
1760
1760
  close: () => void;
1761
1761
  connect: () => void;
1762
+ } | {
1763
+ connected: boolean;
1764
+ attemptedConnectedAtLeastOnce: boolean;
1765
+ trace: () => void;
1766
+ close: () => void;
1767
+ connect: () => void;
1762
1768
  };
1763
1769
  };
1764
1770
 
package/dist/index.mjs CHANGED
@@ -201,9 +201,22 @@ function rtcStatsConnection(wsURL, logger = console) {
201
201
  return connection;
202
202
  }
203
203
  const RTCSTATS_URL = "wss://rtcstats.srv.whereby.com";
204
- const server = rtcStatsConnection(RTCSTATS_URL);
205
- const stats = rtcstats(server.trace, 10000, [""]);
206
- resetDelta = (stats === null || stats === void 0 ? void 0 : stats.resetDelta) || noop;
204
+ const noopServer = {
205
+ connected: false,
206
+ attemptedConnectedAtLeastOnce: false,
207
+ trace: noop,
208
+ close: noop,
209
+ connect: noop,
210
+ };
211
+ let server;
212
+ if (typeof window !== "undefined") {
213
+ server = rtcStatsConnection(RTCSTATS_URL);
214
+ const stats = rtcstats(server.trace, 10000, [""]);
215
+ resetDelta = (stats === null || stats === void 0 ? void 0 : stats.resetDelta) || noop;
216
+ }
217
+ else {
218
+ server = noopServer;
219
+ }
207
220
  const rtcStats = {
208
221
  sendEvent: (type, value) => {
209
222
  server.trace("customEvent", null, {
@@ -220,7 +233,7 @@ const rtcStats = {
220
233
  server,
221
234
  };
222
235
 
223
- const debugOn = new URLSearchParams(window.location.search).has("debug");
236
+ const debugOn = (typeof window !== "undefined" && new URLSearchParams(window.location.search).has("debug"));
224
237
  class Logger {
225
238
  constructor() {
226
239
  this._isEnabled = false;
@@ -1453,7 +1466,7 @@ const peerConnectionData = new WeakMap();
1453
1466
  const removePeerConnection = (pc) => {
1454
1467
  peerConnections = peerConnections.filter((old) => old !== pc);
1455
1468
  };
1456
- if (window.RTCPeerConnection) {
1469
+ if (typeof window !== "undefined" && window.RTCPeerConnection) {
1457
1470
  const OriginalRTCPeerConnection = window.RTCPeerConnection;
1458
1471
  function PatchedRTCPeerConnection(rtcConfig) {
1459
1472
  const pc = new OriginalRTCPeerConnection(rtcConfig);
@@ -2411,7 +2424,7 @@ function fromLocation({ host = "whereby.com", protocol = "https:" } = {}) {
2411
2424
  subdomain,
2412
2425
  };
2413
2426
  }
2414
- fromLocation(window && window.location);
2427
+ fromLocation(typeof window !== "undefined" ? window.location : undefined);
2415
2428
 
2416
2429
  var _a$2, _b$1;
2417
2430
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
@@ -7148,7 +7161,7 @@ class BandwidthTester extends EventEmitter {
7148
7161
  }
7149
7162
 
7150
7163
  const logger = new Logger();
7151
- const isMobile = /mobi/i.test(navigator.userAgent);
7164
+ const isMobile = typeof navigator !== "undefined" && /mobi/i.test(navigator.userAgent);
7152
7165
  class NoDevicesError extends Error {
7153
7166
  constructor(...args) {
7154
7167
  super(...args);
@@ -7406,8 +7419,8 @@ function hasGetDisplayMedia() {
7406
7419
  }
7407
7420
  const defaultDisplayMediaConstraints = {
7408
7421
  video: {
7409
- width: { max: window.screen.width },
7410
- height: { max: window.screen.height },
7422
+ width: { max: typeof window !== "undefined" ? window.screen.width : 0 },
7423
+ height: { max: typeof window !== "undefined" ? window.screen.height : 0 },
7411
7424
  },
7412
7425
  };
7413
7426
  function getDisplayMedia(constraints = defaultDisplayMediaConstraints, contentHint = "detail") {
@@ -201,9 +201,22 @@ function rtcStatsConnection(wsURL, logger = console) {
201
201
  return connection;
202
202
  }
203
203
  const RTCSTATS_URL = "wss://rtcstats.srv.whereby.com";
204
- const server = rtcStatsConnection(RTCSTATS_URL);
205
- const stats = rtcstats(server.trace, 10000, [""]);
206
- resetDelta = (stats === null || stats === void 0 ? void 0 : stats.resetDelta) || noop;
204
+ const noopServer = {
205
+ connected: false,
206
+ attemptedConnectedAtLeastOnce: false,
207
+ trace: noop,
208
+ close: noop,
209
+ connect: noop,
210
+ };
211
+ let server;
212
+ if (typeof window !== "undefined") {
213
+ server = rtcStatsConnection(RTCSTATS_URL);
214
+ const stats = rtcstats(server.trace, 10000, [""]);
215
+ resetDelta = (stats === null || stats === void 0 ? void 0 : stats.resetDelta) || noop;
216
+ }
217
+ else {
218
+ server = noopServer;
219
+ }
207
220
  const rtcStats = {
208
221
  sendEvent: (type, value) => {
209
222
  server.trace("customEvent", null, {
@@ -220,7 +233,7 @@ const rtcStats = {
220
233
  server,
221
234
  };
222
235
 
223
- const debugOn = new URLSearchParams(window.location.search).has("debug");
236
+ const debugOn = (typeof window !== "undefined" && new URLSearchParams(window.location.search).has("debug"));
224
237
  class Logger {
225
238
  constructor() {
226
239
  this._isEnabled = false;
@@ -1453,7 +1466,7 @@ const peerConnectionData = new WeakMap();
1453
1466
  const removePeerConnection = (pc) => {
1454
1467
  peerConnections = peerConnections.filter((old) => old !== pc);
1455
1468
  };
1456
- if (window.RTCPeerConnection) {
1469
+ if (typeof window !== "undefined" && window.RTCPeerConnection) {
1457
1470
  const OriginalRTCPeerConnection = window.RTCPeerConnection;
1458
1471
  function PatchedRTCPeerConnection(rtcConfig) {
1459
1472
  const pc = new OriginalRTCPeerConnection(rtcConfig);
@@ -2411,7 +2424,7 @@ function fromLocation({ host = "whereby.com", protocol = "https:" } = {}) {
2411
2424
  subdomain,
2412
2425
  };
2413
2426
  }
2414
- fromLocation(window && window.location);
2427
+ fromLocation(typeof window !== "undefined" ? window.location : undefined);
2415
2428
 
2416
2429
  var _a$2, _b$1;
2417
2430
  const adapter$2 = (_a$2 = adapterRaw.default) !== null && _a$2 !== void 0 ? _a$2 : adapterRaw;
@@ -7148,7 +7161,7 @@ class BandwidthTester extends EventEmitter {
7148
7161
  }
7149
7162
 
7150
7163
  const logger = new Logger();
7151
- const isMobile = /mobi/i.test(navigator.userAgent);
7164
+ const isMobile = typeof navigator !== "undefined" && /mobi/i.test(navigator.userAgent);
7152
7165
  class NoDevicesError extends Error {
7153
7166
  constructor(...args) {
7154
7167
  super(...args);
@@ -7406,8 +7419,8 @@ function hasGetDisplayMedia() {
7406
7419
  }
7407
7420
  const defaultDisplayMediaConstraints = {
7408
7421
  video: {
7409
- width: { max: window.screen.width },
7410
- height: { max: window.screen.height },
7422
+ width: { max: typeof window !== "undefined" ? window.screen.width : 0 },
7423
+ height: { max: typeof window !== "undefined" ? window.screen.height : 0 },
7411
7424
  },
7412
7425
  };
7413
7426
  function getDisplayMedia(constraints = defaultDisplayMediaConstraints, contentHint = "detail") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "9.3.0",
4
+ "version": "9.3.1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {