Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit f84c0bd

Browse files
committed
Fix adapter and uuid imports for sdk
There's a confusion in ESM and CJS, let's try to fix them by using namespace imports for uuid and `default` wrapper removal for `adapter` (as suggested here: reduxjs/redux-toolkit#1960)
1 parent 701e70f commit f84c0bd

File tree

8 files changed

+25
-10
lines changed

8 files changed

+25
-10
lines changed

src/utils/ServerSocket.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { io } from "socket.io-client";
2-
import adapter from "webrtc-adapter";
2+
import adapterRaw from "webrtc-adapter";
33
import { ReconnectManager } from "./ReconnectManager";
44
import { PROTOCOL_RESPONSES } from "../model/protocol";
55

6+
const adapter = adapterRaw.default ?? adapterRaw;
7+
68
const DEFAULT_SOCKET_PATH = "/protocol/socket.io/v4";
79

810
const NOOP_KEEPALIVE_INTERVAL = 2000;

src/webrtc/Session.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as sdpModifier from "./sdpModifier";
22
import * as statsHelper from "./statsHelper";
33
import { setVideoBandwidthUsingSetParameters } from "./rtcrtpsenderHelper";
4-
import adapter from "webrtc-adapter";
4+
import adapterRaw from "webrtc-adapter";
55
import { MAXIMUM_TURN_BANDWIDTH_UNLIMITED } from "./constants";
66
import Logger from "../utils/Logger";
77

8+
const adapter = adapterRaw.default ?? adapterRaw;
89
const logger = new Logger();
910

1011
export default class Session {

src/webrtc/VegaRtcManager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ import * as CONNECTION_STATUS from "../model/connectionStatusConstants";
44
import ServerSocket from "../utils/ServerSocket";
55
import rtcManagerEvents from "./rtcManagerEvents";
66
import rtcStats from "./rtcStatsService";
7-
import adapter from "webrtc-adapter";
7+
import adapterRaw from "webrtc-adapter";
88
import VegaConnection from "./VegaConnection";
99
import { getMediaSettings, modifyMediaCapabilities } from "../utils/mediaSettings";
1010
import { MEDIA_JITTER_BUFFER_TARGET } from "./constants";
1111
import { getHandler } from "../utils/getHandler";
1212
import assert from "../utils/assert";
13-
import { v4 as uuidv4 } from "uuid";
13+
import * as uuid from "uuid";
1414
import createMicAnalyser from "./VegaMicAnalyser";
1515
import { maybeTurnOnly } from "../utils/transportSettings";
1616
import VegaMediaQualityMonitor from "./VegaMediaQualityMonitor";
1717
import Logger from "../utils/Logger";
1818

19+
const adapter = adapterRaw.default ?? adapterRaw;
1920
const logger = new Logger();
21+
const uuidv4 = uuid.v4;
2022

2123
const browserName = adapter.browserDetails.browser;
2224
let unloading = false;

src/webrtc/bugDetector.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import adapter from "webrtc-adapter";
1+
import adapterRaw from "webrtc-adapter";
2+
3+
const adapter = adapterRaw.default ?? adapterRaw;
24

35
/**
46
* Detect mic issue which seems to happen on OSX when the computer is woken up and sleeping

src/webrtc/mediaConstraints.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import adapter from "webrtc-adapter";
1+
import adapterRaw from "webrtc-adapter";
2+
3+
const adapter = adapterRaw.default ?? adapterRaw;
24

35
const isSafari = adapter.browserDetails.browser === "safari";
46

src/webrtc/rtcStatsService.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// ensure adapter is loaded first.
2-
import adapter from "webrtc-adapter"; // eslint-disable-line no-unused-vars
2+
import adapterRaw from "webrtc-adapter";
33
import rtcstats from "rtcstats";
4-
import { v4 as uuidv4 } from "uuid";
4+
import * as uuid from "uuid";
5+
6+
const adapter = adapterRaw.default ?? adapterRaw; // eslint-disable-line no-unused-vars
7+
const uuidv4 = uuid.v4;
58

69
const RTCSTATS_PROTOCOL_VERSION = "1.0";
710

src/webrtc/sdpModifier.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import SDPUtils from "sdp";
2-
import adapter from "webrtc-adapter";
2+
import adapterRaw from "webrtc-adapter";
33
import * as sdpTransform from "sdp-transform";
44
import Logger from "../utils/Logger";
55

6+
const adapter = adapterRaw.default ?? adapterRaw;
67
const logger = new Logger();
78

89
const browserName = adapter.browserDetails.browser;

tests/webrtc/RtcManagerDispatcher.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import * as mediasoupClient from "mediasoup-client";
77
import { PROTOCOL_RESPONSES } from "../../src/model/protocol";
88
import * as CONNECTION_STATUS from "../../src/model/connectionStatusConstants";
99
import EventEmitter from "events";
10-
import { v4 as uuidv4 } from "uuid";
10+
import * as uuid from "uuid";
11+
12+
const uuidv4 = uuid.v4;
1113

1214
const originalMediasoupDevice = mediasoupClient.Device;
1315

0 commit comments

Comments
 (0)