node-datachannel 0.25.0 → 0.27.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/CMakeLists.txt +29 -10
- package/dist/cjs/lib/index.cjs +1 -3
- package/dist/cjs/lib/index.cjs.map +1 -1
- package/dist/cjs/polyfill/Events.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCDataChannel.cjs +2 -0
- package/dist/cjs/polyfill/RTCDataChannel.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCError.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCIceTransport.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCPeerConnection.cjs +1 -1
- package/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCSctpTransport.cjs.map +1 -1
- package/dist/esm/lib/index.mjs +1 -3
- package/dist/esm/lib/index.mjs.map +1 -1
- package/dist/esm/polyfill/Events.mjs.map +1 -1
- package/dist/esm/polyfill/RTCDataChannel.mjs +2 -0
- package/dist/esm/polyfill/RTCDataChannel.mjs.map +1 -1
- package/dist/esm/polyfill/RTCDtlsTransport.mjs.map +1 -1
- package/dist/esm/polyfill/RTCError.mjs.map +1 -1
- package/dist/esm/polyfill/RTCIceTransport.mjs.map +1 -1
- package/dist/esm/polyfill/RTCPeerConnection.mjs +1 -1
- package/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -1
- package/dist/esm/polyfill/RTCSctpTransport.mjs.map +1 -1
- package/dist/types/lib/index.d.ts +5 -2
- package/dist/types/polyfill/Events.d.ts +3 -6
- package/dist/types/polyfill/RTCDataChannel.d.ts +6 -6
- package/dist/types/polyfill/RTCDtlsTransport.d.ts +5 -8
- package/dist/types/polyfill/RTCIceTransport.d.ts +6 -9
- package/dist/types/polyfill/RTCPeerConnection.d.ts +20 -22
- package/dist/types/polyfill/RTCSctpTransport.d.ts +3 -6
- package/package.json +112 -102
- package/src/cpp/main.cpp +14 -0
- package/src/cpp/peer-connection-wrapper.cpp +9 -1
- package/src/cpp/peer-connection-wrapper.h +5 -1
- package/src/cpp/rtc-wrapper.cpp +18 -0
- package/src/lib/index.ts +5 -2
- package/src/polyfill/Events.ts +6 -10
- package/src/polyfill/RTCDataChannel.ts +9 -7
- package/src/polyfill/RTCDtlsTransport.ts +6 -7
- package/src/polyfill/RTCError.ts +1 -1
- package/src/polyfill/RTCIceTransport.ts +7 -8
- package/src/polyfill/RTCPeerConnection.ts +31 -30
- package/src/polyfill/RTCSctpTransport.ts +5 -6
package/package.json
CHANGED
|
@@ -1,107 +1,117 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"install": "prebuild-install -r napi || (npm install --ignore-scripts --production=false && npm run _prebuild)",
|
|
27
|
-
"install:nice": "npm run clean && npm install --ignore-scripts --production=false && cmake-js build --CDUSE_NICE=1",
|
|
28
|
-
"install:gnu": "npm run clean && npm install --ignore-scripts --production=false && cmake-js build --CDUSE_GNUTLS=1",
|
|
29
|
-
"build": "npm run compile && npm run build:tsc",
|
|
30
|
-
"compile": "cmake-js build",
|
|
31
|
-
"compile:debug": "cmake-js build -D",
|
|
32
|
-
"build:tsc": "rimraf dist && rollup -c",
|
|
33
|
-
"build:tsc:watch": "rollup -c -w",
|
|
34
|
-
"clean": "rimraf dist build",
|
|
35
|
-
"lint": "eslint . --ext .ts --ext .mts",
|
|
36
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
37
|
-
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
|
|
38
|
-
"test:wpt": "npm run run:wpt:server & (sleep 8 && (npm run run:wpt:test | tee test/wpt-tests/last-test-results.md) )",
|
|
39
|
-
"wpt:server": "cd test/wpt-tests/wpt && ./wpt serve",
|
|
40
|
-
"wpt:test": "ts-node test/wpt-tests/index.ts",
|
|
41
|
-
"_prebuild": "prebuild -r napi --backend cmake-js",
|
|
42
|
-
"prepack": "npm run build:tsc"
|
|
43
|
-
},
|
|
44
|
-
"binary": {
|
|
45
|
-
"napi_versions": [
|
|
46
|
-
8
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
"repository": {
|
|
50
|
-
"type": "git",
|
|
51
|
-
"url": "git+https://github.com/murat-dogan/node-datachannel.git"
|
|
52
|
-
},
|
|
53
|
-
"keywords": [
|
|
54
|
-
"libdatachannel",
|
|
55
|
-
"webrtc",
|
|
56
|
-
"p2p",
|
|
57
|
-
"peer-to-peer",
|
|
58
|
-
"datachannel",
|
|
59
|
-
"data channel",
|
|
60
|
-
"websocket"
|
|
61
|
-
],
|
|
62
|
-
"contributors": [
|
|
63
|
-
{
|
|
64
|
-
"name": "Murat Doğan",
|
|
65
|
-
"url": "https://github.com/murat-dogan"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"name": "Paul-Louis Ageneau",
|
|
69
|
-
"url": "https://github.com/paullouisageneau"
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
"license": "MPL 2.0",
|
|
73
|
-
"bugs": {
|
|
74
|
-
"url": "https://github.com/murat-dogan/node-datachannel/issues"
|
|
2
|
+
"name": "node-datachannel",
|
|
3
|
+
"version": "0.27.0",
|
|
4
|
+
"description": "WebRTC For Node.js and Electron. libdatachannel node bindings.",
|
|
5
|
+
"main": "./dist/cjs/lib/index.cjs",
|
|
6
|
+
"module": "./dist/esm/lib/index.mjs",
|
|
7
|
+
"types": "./dist/types/lib/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"*": {
|
|
10
|
+
"*": [
|
|
11
|
+
"dist/types/lib/index.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"polyfill": [
|
|
14
|
+
"dist/types/polyfill/index.d.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/types/lib/index.d.ts",
|
|
21
|
+
"require": "./dist/cjs/lib/index.cjs",
|
|
22
|
+
"import": "./dist/esm/lib/index.mjs",
|
|
23
|
+
"default": "./dist/lib/esm/index.mjs"
|
|
75
24
|
},
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
25
|
+
"./polyfill": {
|
|
26
|
+
"types": "./dist/types/polyfill/index.d.ts",
|
|
27
|
+
"require": "./dist/cjs/polyfill/index.cjs",
|
|
28
|
+
"import": "./dist/esm/polyfill/index.mjs",
|
|
29
|
+
"default": "./dist/polyfill/esm/index.mjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18.20.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"install": "prebuild-install -r napi || (npm install --ignore-scripts --production=false && npm run _prebuild)",
|
|
37
|
+
"install:nice": "npm run clean && npm install --ignore-scripts --production=false && cmake-js configure --CDUSE_NICE=1 && cmake-js build",
|
|
38
|
+
"install:gnu": "npm run clean && npm install --ignore-scripts --production=false && cmake-js configure --CDUSE_GNUTLS=1 && cmake-js build",
|
|
39
|
+
"build": "npm run compile && npm run build:tsc",
|
|
40
|
+
"compile": "cmake-js build",
|
|
41
|
+
"compile:debug": "cmake-js build -D",
|
|
42
|
+
"build:tsc": "rimraf dist && rollup -c",
|
|
43
|
+
"build:tsc:watch": "rollup -c -w",
|
|
44
|
+
"clean": "rimraf dist build",
|
|
45
|
+
"lint": "eslint . --ext .ts --ext .mts",
|
|
46
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
47
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
|
|
48
|
+
"test:wpt": "npm run run:wpt:server & (sleep 8 && (npm run run:wpt:test | tee test/wpt-tests/last-test-results.md) )",
|
|
49
|
+
"wpt:server": "cd test/wpt-tests/wpt && ./wpt serve",
|
|
50
|
+
"wpt:test": "ts-node test/wpt-tests/index.ts",
|
|
51
|
+
"_prebuild": "prebuild -r napi --backend cmake-js",
|
|
52
|
+
"prepack": "npm run build:tsc"
|
|
53
|
+
},
|
|
54
|
+
"binary": {
|
|
55
|
+
"napi_versions": [
|
|
56
|
+
8
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "git+https://github.com/murat-dogan/node-datachannel.git"
|
|
62
|
+
},
|
|
63
|
+
"keywords": [
|
|
64
|
+
"libdatachannel",
|
|
65
|
+
"webrtc",
|
|
66
|
+
"p2p",
|
|
67
|
+
"peer-to-peer",
|
|
68
|
+
"datachannel",
|
|
69
|
+
"data channel",
|
|
70
|
+
"websocket"
|
|
71
|
+
],
|
|
72
|
+
"contributors": [
|
|
73
|
+
{
|
|
74
|
+
"name": "Murat Doğan",
|
|
75
|
+
"url": "https://github.com/murat-dogan"
|
|
103
76
|
},
|
|
104
|
-
|
|
105
|
-
|
|
77
|
+
{
|
|
78
|
+
"name": "Paul-Louis Ageneau",
|
|
79
|
+
"url": "https://github.com/paullouisageneau"
|
|
106
80
|
}
|
|
81
|
+
],
|
|
82
|
+
"license": "MPL 2.0",
|
|
83
|
+
"bugs": {
|
|
84
|
+
"url": "https://github.com/murat-dogan/node-datachannel/issues"
|
|
85
|
+
},
|
|
86
|
+
"homepage": "https://github.com/murat-dogan/node-datachannel#readme",
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@rollup/plugin-esm-shim": "^0.1.7",
|
|
89
|
+
"@rollup/plugin-replace": "^6.0.1",
|
|
90
|
+
"@types/jest": "^29.5.12",
|
|
91
|
+
"@types/node": "^20.6.1",
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
93
|
+
"@typescript-eslint/parser": "^7.17.0",
|
|
94
|
+
"cmake-js": "^7.3.0",
|
|
95
|
+
"eslint": "^8.57.0",
|
|
96
|
+
"eslint-config-prettier": "^9.1.0",
|
|
97
|
+
"eslint-plugin-jest": "^28.6.0",
|
|
98
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
99
|
+
"jest": "^29.7.0",
|
|
100
|
+
"jsdom": "^24.1.1",
|
|
101
|
+
"node-addon-api": "^7.0.0",
|
|
102
|
+
"prebuild": "^13.0.1",
|
|
103
|
+
"prettier": "^3.3.3",
|
|
104
|
+
"puppeteer": "^22.14.0",
|
|
105
|
+
"rimraf": "^5.0.9",
|
|
106
|
+
"rollup": "^4.22.5",
|
|
107
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
108
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
109
|
+
"ts-api-utils": "^1.3.0",
|
|
110
|
+
"ts-jest": "^29.2.3",
|
|
111
|
+
"ts-node": "^10.9.2",
|
|
112
|
+
"typescript": "5.4"
|
|
113
|
+
},
|
|
114
|
+
"dependencies": {
|
|
115
|
+
"prebuild-install": "^7.1.3"
|
|
116
|
+
}
|
|
107
117
|
}
|
package/src/cpp/main.cpp
CHANGED
|
@@ -2,24 +2,38 @@
|
|
|
2
2
|
#include "rtc-wrapper.h"
|
|
3
3
|
#include "peer-connection-wrapper.h"
|
|
4
4
|
#include "data-channel-wrapper.h"
|
|
5
|
+
|
|
6
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
5
7
|
#include "media-rtcpreceivingsession-wrapper.h"
|
|
6
8
|
#include "media-track-wrapper.h"
|
|
7
9
|
#include "media-video-wrapper.h"
|
|
8
10
|
#include "media-audio-wrapper.h"
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#if RTC_ENABLE_WEBSOCKET == 1
|
|
9
14
|
#include "web-socket-wrapper.h"
|
|
10
15
|
#include "web-socket-server-wrapper.h"
|
|
16
|
+
#endif
|
|
11
17
|
|
|
12
18
|
Napi::Object InitAll(Napi::Env env, Napi::Object exports)
|
|
13
19
|
{
|
|
14
20
|
RtcWrapper::Init(env, exports);
|
|
21
|
+
|
|
22
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
15
23
|
RtcpReceivingSessionWrapper::Init(env, exports);
|
|
16
24
|
TrackWrapper::Init(env, exports);
|
|
17
25
|
VideoWrapper::Init(env, exports);
|
|
18
26
|
AudioWrapper::Init(env, exports);
|
|
27
|
+
#endif
|
|
28
|
+
|
|
19
29
|
DataChannelWrapper::Init(env, exports);
|
|
20
30
|
PeerConnectionWrapper::Init(env, exports);
|
|
31
|
+
|
|
32
|
+
#if RTC_ENABLE_WEBSOCKET == 1
|
|
21
33
|
WebSocketWrapper::Init(env, exports);
|
|
22
34
|
WebSocketServerWrapper::Init(env, exports);
|
|
35
|
+
#endif
|
|
36
|
+
|
|
23
37
|
return exports;
|
|
24
38
|
}
|
|
25
39
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
#include "peer-connection-wrapper.h"
|
|
2
2
|
#include "data-channel-wrapper.h"
|
|
3
|
+
|
|
4
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
3
5
|
#include "media-track-wrapper.h"
|
|
4
6
|
#include "media-video-wrapper.h"
|
|
5
7
|
#include "media-audio-wrapper.h"
|
|
8
|
+
#endif
|
|
6
9
|
|
|
7
10
|
#include "plog/Log.h"
|
|
8
11
|
|
|
@@ -43,7 +46,11 @@ Napi::Object PeerConnectionWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
|
43
46
|
InstanceMethod("remoteDescription", &PeerConnectionWrapper::remoteDescription),
|
|
44
47
|
InstanceMethod("addRemoteCandidate", &PeerConnectionWrapper::addRemoteCandidate),
|
|
45
48
|
InstanceMethod("createDataChannel", &PeerConnectionWrapper::createDataChannel),
|
|
49
|
+
|
|
50
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
46
51
|
InstanceMethod("addTrack", &PeerConnectionWrapper::addTrack),
|
|
52
|
+
InstanceMethod("onTrack", &PeerConnectionWrapper::onTrack),
|
|
53
|
+
#endif
|
|
47
54
|
InstanceMethod("hasMedia", &PeerConnectionWrapper::hasMedia),
|
|
48
55
|
InstanceMethod("state", &PeerConnectionWrapper::state),
|
|
49
56
|
InstanceMethod("iceState", &PeerConnectionWrapper::iceState),
|
|
@@ -56,7 +63,6 @@ Napi::Object PeerConnectionWrapper::Init(Napi::Env env, Napi::Object exports)
|
|
|
56
63
|
InstanceMethod("onSignalingStateChange", &PeerConnectionWrapper::onSignalingStateChange),
|
|
57
64
|
InstanceMethod("onGatheringStateChange", &PeerConnectionWrapper::onGatheringStateChange),
|
|
58
65
|
InstanceMethod("onDataChannel", &PeerConnectionWrapper::onDataChannel),
|
|
59
|
-
InstanceMethod("onTrack", &PeerConnectionWrapper::onTrack),
|
|
60
66
|
InstanceMethod("bytesSent", &PeerConnectionWrapper::bytesSent),
|
|
61
67
|
InstanceMethod("bytesReceived", &PeerConnectionWrapper::bytesReceived),
|
|
62
68
|
InstanceMethod("rtt", &PeerConnectionWrapper::rtt),
|
|
@@ -1049,6 +1055,7 @@ std::string PeerConnectionWrapper::candidateTransportTypeToString(const rtc::Can
|
|
|
1049
1055
|
}
|
|
1050
1056
|
}
|
|
1051
1057
|
|
|
1058
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
1052
1059
|
Napi::Value PeerConnectionWrapper::addTrack(const Napi::CallbackInfo &info)
|
|
1053
1060
|
{
|
|
1054
1061
|
PLOG_DEBUG << "addTrack() called";
|
|
@@ -1132,6 +1139,7 @@ void PeerConnectionWrapper::onTrack(const Napi::CallbackInfo &info)
|
|
|
1132
1139
|
args = {instance};
|
|
1133
1140
|
}); });
|
|
1134
1141
|
}
|
|
1142
|
+
#endif
|
|
1135
1143
|
|
|
1136
1144
|
Napi::Value PeerConnectionWrapper::hasMedia(const Napi::CallbackInfo &info)
|
|
1137
1145
|
{
|
|
@@ -27,7 +27,12 @@ public:
|
|
|
27
27
|
Napi::Value remoteDescription(const Napi::CallbackInfo &info);
|
|
28
28
|
void addRemoteCandidate(const Napi::CallbackInfo &info);
|
|
29
29
|
Napi::Value createDataChannel(const Napi::CallbackInfo &info);
|
|
30
|
+
|
|
31
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
30
32
|
Napi::Value addTrack(const Napi::CallbackInfo &info);
|
|
33
|
+
void onTrack(const Napi::CallbackInfo &info);
|
|
34
|
+
#endif
|
|
35
|
+
|
|
31
36
|
Napi::Value hasMedia(const Napi::CallbackInfo &info);
|
|
32
37
|
Napi::Value state(const Napi::CallbackInfo &info);
|
|
33
38
|
Napi::Value iceState(const Napi::CallbackInfo &info);
|
|
@@ -42,7 +47,6 @@ public:
|
|
|
42
47
|
void onSignalingStateChange(const Napi::CallbackInfo &info);
|
|
43
48
|
void onGatheringStateChange(const Napi::CallbackInfo &info);
|
|
44
49
|
void onDataChannel(const Napi::CallbackInfo &info);
|
|
45
|
-
void onTrack(const Napi::CallbackInfo &info);
|
|
46
50
|
|
|
47
51
|
// Stats
|
|
48
52
|
Napi::Value bytesSent(const Napi::CallbackInfo &info);
|
package/src/cpp/rtc-wrapper.cpp
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
#include "rtc-wrapper.h"
|
|
2
2
|
#include "peer-connection-wrapper.h"
|
|
3
3
|
#include "data-channel-wrapper.h"
|
|
4
|
+
|
|
5
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
4
6
|
#include "media-track-wrapper.h"
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#if RTC_ENABLE_WEBSOCKET == 1
|
|
5
10
|
#include "web-socket-wrapper.h"
|
|
6
11
|
#include "web-socket-server-wrapper.h"
|
|
12
|
+
#endif
|
|
7
13
|
|
|
8
14
|
#include "plog/Log.h"
|
|
9
15
|
|
|
@@ -118,9 +124,15 @@ void RtcWrapper::cleanup(const Napi::CallbackInfo &info)
|
|
|
118
124
|
{
|
|
119
125
|
PeerConnectionWrapper::CloseAll();
|
|
120
126
|
DataChannelWrapper::CloseAll();
|
|
127
|
+
|
|
128
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
121
129
|
TrackWrapper::CloseAll();
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
#if RTC_ENABLE_WEBSOCKET == 1
|
|
122
133
|
WebSocketWrapper::CloseAll();
|
|
123
134
|
WebSocketServerWrapper::StopAll();
|
|
135
|
+
#endif
|
|
124
136
|
|
|
125
137
|
const auto timeout = std::chrono::seconds(10);
|
|
126
138
|
if (rtc::Cleanup().wait_for(std::chrono::seconds(timeout)) == std::future_status::timeout)
|
|
@@ -129,8 +141,14 @@ void RtcWrapper::cleanup(const Napi::CallbackInfo &info)
|
|
|
129
141
|
// Cleanup the instances
|
|
130
142
|
PeerConnectionWrapper::CleanupAll();
|
|
131
143
|
DataChannelWrapper::CleanupAll();
|
|
144
|
+
|
|
145
|
+
#if RTC_ENABLE_MEDIA == 1
|
|
132
146
|
TrackWrapper::CleanupAll();
|
|
147
|
+
#endif
|
|
148
|
+
|
|
149
|
+
#if RTC_ENABLE_WEBSOCKET == 1
|
|
133
150
|
WebSocketWrapper::CleanupAll();
|
|
151
|
+
#endif
|
|
134
152
|
|
|
135
153
|
if (logCallback)
|
|
136
154
|
logCallback.reset();
|
package/src/lib/index.ts
CHANGED
|
@@ -145,10 +145,13 @@ export const PeerConnection: {
|
|
|
145
145
|
new(peerName: string, config: RtcConfig): PeerConnection
|
|
146
146
|
} = nodeDataChannel.PeerConnection
|
|
147
147
|
|
|
148
|
-
export
|
|
149
|
-
//
|
|
148
|
+
export interface RtcpReceivingSession {
|
|
150
149
|
}
|
|
151
150
|
|
|
151
|
+
export const RtcpReceivingSession: {
|
|
152
|
+
new(): RtcpReceivingSession
|
|
153
|
+
} = nodeDataChannel.RtcpReceivingSession
|
|
154
|
+
|
|
152
155
|
export { WebSocketServer } from './websocket-server';
|
|
153
156
|
export { WebSocket } from './websocket';
|
|
154
157
|
|
package/src/polyfill/Events.ts
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import RTCDataChannel from './RTCDataChannel';
|
|
2
|
-
import RTCIceCandidate from './RTCIceCandidate';
|
|
3
|
-
|
|
4
|
-
|
|
5
1
|
export class RTCPeerConnectionIceEvent extends Event implements globalThis.RTCPeerConnectionIceEvent {
|
|
6
|
-
#candidate: RTCIceCandidate;
|
|
2
|
+
#candidate: globalThis.RTCIceCandidate;
|
|
7
3
|
|
|
8
|
-
constructor(candidate: RTCIceCandidate) {
|
|
4
|
+
constructor(candidate: globalThis.RTCIceCandidate) {
|
|
9
5
|
super('icecandidate');
|
|
10
6
|
|
|
11
7
|
this.#candidate = candidate;
|
|
12
8
|
}
|
|
13
9
|
|
|
14
|
-
get candidate(): RTCIceCandidate {
|
|
10
|
+
get candidate(): globalThis.RTCIceCandidate {
|
|
15
11
|
return this.#candidate;
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
export class RTCDataChannelEvent extends Event implements globalThis.RTCDataChannelEvent {
|
|
20
|
-
#channel: RTCDataChannel;
|
|
16
|
+
#channel: globalThis.RTCDataChannel;
|
|
21
17
|
|
|
22
18
|
constructor(type: string, eventInitDict: globalThis.RTCDataChannelEventInit) {
|
|
23
19
|
super(type);
|
|
24
20
|
|
|
25
21
|
if (type && !eventInitDict.channel) throw new TypeError('channel member is required');
|
|
26
22
|
|
|
27
|
-
this.#channel = eventInitDict?.channel as RTCDataChannel;
|
|
23
|
+
this.#channel = eventInitDict?.channel as globalThis.RTCDataChannel;
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
get channel(): RTCDataChannel {
|
|
26
|
+
get channel(): globalThis.RTCDataChannel {
|
|
31
27
|
return this.#channel;
|
|
32
28
|
}
|
|
33
29
|
}
|
|
@@ -4,7 +4,7 @@ import { DataChannel } from '../lib/index';
|
|
|
4
4
|
|
|
5
5
|
export default class RTCDataChannel extends EventTarget implements globalThis.RTCDataChannel {
|
|
6
6
|
#dataChannel: DataChannel;
|
|
7
|
-
#readyState: RTCDataChannelState;
|
|
7
|
+
#readyState: globalThis.RTCDataChannelState;
|
|
8
8
|
#bufferedAmountLowThreshold: number;
|
|
9
9
|
#binaryType: BinaryType;
|
|
10
10
|
#maxPacketLifeTime: number | null;
|
|
@@ -15,12 +15,12 @@ export default class RTCDataChannel extends EventTarget implements globalThis.RT
|
|
|
15
15
|
#closeRequested = false;
|
|
16
16
|
|
|
17
17
|
// events
|
|
18
|
-
onbufferedamountlow: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
19
|
-
onclose: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
20
|
-
onclosing: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
21
|
-
onerror: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
22
|
-
onmessage: ((this: RTCDataChannel, ev: MessageEvent) => any) | null;
|
|
23
|
-
onopen: ((this: RTCDataChannel, ev: Event) => any) | null;
|
|
18
|
+
onbufferedamountlow: ((this: globalThis.RTCDataChannel, ev: Event) => any) | null;
|
|
19
|
+
onclose: ((this: globalThis.RTCDataChannel, ev: Event) => any) | null;
|
|
20
|
+
onclosing: ((this: globalThis.RTCDataChannel, ev: Event) => any) | null;
|
|
21
|
+
onerror: ((this: globalThis.RTCDataChannel, ev: Event) => any) | null;
|
|
22
|
+
onmessage: ((this: globalThis.RTCDataChannel, ev: MessageEvent) => any) | null;
|
|
23
|
+
onopen: ((this: globalThis.RTCDataChannel, ev: Event) => any) | null;
|
|
24
24
|
|
|
25
25
|
constructor(dataChannel: DataChannel, opts: globalThis.RTCDataChannelInit = {}) {
|
|
26
26
|
super();
|
|
@@ -180,6 +180,8 @@ export default class RTCDataChannel extends EventTarget implements globalThis.RT
|
|
|
180
180
|
this.#dataChannel.sendMessageBinary(new Uint8Array(ab));
|
|
181
181
|
}
|
|
182
182
|
});
|
|
183
|
+
} else if (data instanceof Uint8Array) {
|
|
184
|
+
this.#dataChannel.sendMessageBinary(data);
|
|
183
185
|
} else {
|
|
184
186
|
if (process?.versions?.bun) {
|
|
185
187
|
this.#dataChannel.sendMessageBinary(Buffer.from(data));
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import RTCIceTransport from './RTCIceTransport';
|
|
3
|
-
import RTCPeerConnection from './RTCPeerConnection';
|
|
4
3
|
|
|
5
4
|
export default class RTCDtlsTransport extends EventTarget implements globalThis.RTCDtlsTransport {
|
|
6
|
-
#pc: RTCPeerConnection = null;
|
|
5
|
+
#pc: globalThis.RTCPeerConnection = null;
|
|
7
6
|
#iceTransport = null;
|
|
8
7
|
|
|
9
|
-
onstatechange: ((this: RTCDtlsTransport, ev: Event) => any) | null = null;
|
|
10
|
-
onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null = null;
|
|
8
|
+
onstatechange: ((this: globalThis.RTCDtlsTransport, ev: Event) => any) | null = null;
|
|
9
|
+
onerror: ((this: globalThis.RTCDtlsTransport, ev: Event) => any) | null = null;
|
|
11
10
|
|
|
12
|
-
constructor(init: { pc: RTCPeerConnection, extraFunctions }) {
|
|
11
|
+
constructor(init: { pc: globalThis.RTCPeerConnection, extraFunctions }) {
|
|
13
12
|
super();
|
|
14
13
|
this.#pc = init.pc;
|
|
15
14
|
|
|
@@ -26,11 +25,11 @@ export default class RTCDtlsTransport extends EventTarget implements globalThis.
|
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
get iceTransport(): RTCIceTransport {
|
|
28
|
+
get iceTransport(): globalThis.RTCIceTransport {
|
|
30
29
|
return this.#iceTransport;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
get state(): RTCDtlsTransportState {
|
|
32
|
+
get state(): globalThis.RTCDtlsTransportState {
|
|
34
33
|
// reduce state from new, connecting, connected, disconnected, failed, closed, unknown
|
|
35
34
|
// to RTCDtlsTRansport states new, connecting, connected, closed, failed
|
|
36
35
|
let state = this.#pc ? this.#pc.connectionState : 'new';
|
package/src/polyfill/RTCError.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import RTCIceCandidate from './RTCIceCandidate';
|
|
3
|
-
import RTCPeerConnection from './RTCPeerConnection';
|
|
4
3
|
|
|
5
4
|
export default class RTCIceTransport extends EventTarget implements globalThis.RTCIceTransport {
|
|
6
|
-
#pc: RTCPeerConnection = null;
|
|
5
|
+
#pc: globalThis.RTCPeerConnection = null;
|
|
7
6
|
#extraFunctions = null;
|
|
8
7
|
|
|
9
|
-
ongatheringstatechange: ((this: RTCIceTransport, ev: Event) => any) | null = null;
|
|
10
|
-
onselectedcandidatepairchange: ((this: RTCIceTransport, ev: Event) => any) | null = null;
|
|
11
|
-
onstatechange: ((this: RTCIceTransport, ev: Event) => any) | null = null;
|
|
8
|
+
ongatheringstatechange: ((this: globalThis.RTCIceTransport, ev: Event) => any) | null = null;
|
|
9
|
+
onselectedcandidatepairchange: ((this: globalThis.RTCIceTransport, ev: Event) => any) | null = null;
|
|
10
|
+
onstatechange: ((this: globalThis.RTCIceTransport, ev: Event) => any) | null = null;
|
|
12
11
|
|
|
13
|
-
constructor(init: { pc: RTCPeerConnection, extraFunctions }) {
|
|
12
|
+
constructor(init: { pc: globalThis.RTCPeerConnection, extraFunctions }) {
|
|
14
13
|
super();
|
|
15
14
|
this.#pc = init.pc;
|
|
16
15
|
this.#extraFunctions = init.extraFunctions;
|
|
@@ -50,7 +49,7 @@ export default class RTCIceTransport extends EventTarget implements globalThis.R
|
|
|
50
49
|
return this.#pc ? this.#pc.iceConnectionState : 'new';
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
getLocalCandidates(): RTCIceCandidate[] {
|
|
52
|
+
getLocalCandidates(): globalThis.RTCIceCandidate[] {
|
|
54
53
|
return this.#pc ? this.#extraFunctions.localCandidates() : [];
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -58,7 +57,7 @@ export default class RTCIceTransport extends EventTarget implements globalThis.R
|
|
|
58
57
|
/** */
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
getRemoteCandidates(): RTCIceCandidate[] {
|
|
60
|
+
getRemoteCandidates(): globalThis.RTCIceCandidate[] {
|
|
62
61
|
return this.#pc ? this.#extraFunctions.remoteCandidates() : [];
|
|
63
62
|
}
|
|
64
63
|
|