node-datachannel 0.12.0 → 0.20.0-alpha.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/.eslintignore +5 -1
- package/.eslintrc.json +27 -0
- package/.prettierrc +12 -0
- package/CMakeLists.txt +13 -13
- package/jest.config.ts +14 -0
- package/package.json +46 -43
- package/rollup.config.mjs +63 -0
- package/src/index.ts +10 -0
- package/{lib/datachannel-stream.js → src/lib/datachannel-stream.ts} +16 -11
- package/src/lib/index.ts +180 -0
- package/src/lib/node-datachannel.ts +13 -0
- package/src/lib/types.ts +126 -0
- package/{lib/websocket-server.js → src/lib/websocket-server.ts} +10 -8
- package/src/lib/websocket.ts +26 -0
- package/src/polyfill/Events.ts +33 -0
- package/src/polyfill/Exception.ts +37 -0
- package/src/polyfill/RTCCertificate.ts +17 -0
- package/{polyfill/RTCDataChannel.js → src/polyfill/RTCDataChannel.ts} +43 -40
- package/src/polyfill/RTCDtlsTransport.ts +47 -0
- package/src/polyfill/RTCError.ts +71 -0
- package/{polyfill/RTCIceCandidate.js → src/polyfill/RTCIceCandidate.ts} +35 -35
- package/{polyfill/RTCIceTransport.js → src/polyfill/RTCIceTransport.ts} +22 -20
- package/{polyfill/RTCPeerConnection.js → src/polyfill/RTCPeerConnection.ts} +128 -114
- package/{polyfill/RTCSctpTransport.js → src/polyfill/RTCSctpTransport.ts} +16 -14
- package/{polyfill/RTCSessionDescription.js → src/polyfill/RTCSessionDescription.ts} +7 -12
- package/{polyfill/index.js → src/polyfill/index.ts} +10 -10
- package/tsconfig.json +20 -13
- package/.eslintrc.cjs +0 -8
- package/.github/FUNDING.yml +0 -2
- package/.github/workflows/build-linux.yml +0 -109
- package/.github/workflows/build-mac-m1.yml +0 -38
- package/.github/workflows/build-mac-x64.yml +0 -40
- package/.github/workflows/build-win.yml +0 -74
- package/.github/workflows/lint.yml +0 -20
- package/.github/workflows/npm-publish-manual.yml +0 -23
- package/.prettierrc.cjs +0 -8
- package/build-containers/Dockerfile.alpine +0 -6
- package/build-containers/Dockerfile.debian +0 -7
- package/cmake/toolchain/ci.cmake +0 -23
- package/examples/client-server/README.md +0 -22
- package/examples/client-server/client-benchmark.js +0 -230
- package/examples/client-server/client-periodic.js +0 -189
- package/examples/client-server/client.js +0 -111
- package/examples/client-server/package-lock.json +0 -289
- package/examples/client-server/package.json +0 -16
- package/examples/client-server/signaling-server.js +0 -39
- package/examples/electron-demo/README.md +0 -58
- package/examples/electron-demo/forge.config.js +0 -49
- package/examples/electron-demo/package-lock.json +0 -15877
- package/examples/electron-demo/package.json +0 -44
- package/examples/electron-demo/src/index.css +0 -7
- package/examples/electron-demo/src/index.html +0 -29
- package/examples/electron-demo/src/main.js +0 -53
- package/examples/electron-demo/src/node-datachannel.js +0 -123
- package/examples/electron-demo/src/preload.js +0 -28
- package/examples/electron-demo/src/renderer.js +0 -58
- package/examples/electron-demo/webpack.main.config.js +0 -21
- package/examples/electron-demo/webpack.renderer.config.js +0 -13
- package/examples/electron-demo/webpack.rules.js +0 -35
- package/examples/media/README.md +0 -34
- package/examples/media/main.html +0 -45
- package/examples/media/media.js +0 -54
- package/examples/simple-peer-usage/main.js +0 -28
- package/examples/simple-peer-usage/package-lock.json +0 -317
- package/examples/simple-peer-usage/package.json +0 -16
- package/examples/websocket/websocket-client.js +0 -20
- package/examples/websocket/websocket-server.js +0 -22
- package/jest.config.cjs +0 -7
- package/lib/index.cjs +0 -194
- package/lib/index.d.cts +0 -300
- package/lib/index.d.ts +0 -300
- package/lib/index.js +0 -58
- package/lib/node-datachannel.js +0 -7
- package/polyfill/Events.d.ts +0 -9
- package/polyfill/Events.js +0 -29
- package/polyfill/Exception.js +0 -23
- package/polyfill/RTCCertificate.d.ts +0 -7
- package/polyfill/RTCCertificate.js +0 -17
- package/polyfill/RTCDataChannel.d.ts +0 -35
- package/polyfill/RTCDtlsTransport.d.ts +0 -10
- package/polyfill/RTCDtlsTransport.js +0 -47
- package/polyfill/RTCError.d.ts +0 -11
- package/polyfill/RTCError.js +0 -65
- package/polyfill/RTCIceCandidate.d.ts +0 -20
- package/polyfill/RTCIceTransport.d.ts +0 -18
- package/polyfill/RTCPeerConnection.d.ts +0 -62
- package/polyfill/RTCSctpTransport.d.ts +0 -10
- package/polyfill/RTCSessionDescription.d.ts +0 -8
- package/polyfill/index.cjs +0 -1333
- package/polyfill/index.d.cts +0 -37
- package/polyfill/index.d.ts +0 -37
- package/test/connectivity.js +0 -86
- package/test/jest-tests/basic.test.js +0 -37
- package/test/jest-tests/multiple-run.test.js +0 -73
- package/test/jest-tests/p2p.test.js +0 -99
- package/test/jest-tests/polyfill.test.js +0 -10
- package/test/jest-tests/streams.test.js +0 -48
- package/test/jest-tests/websocket.test.js +0 -69
- package/test/polyfill-connectivity.js +0 -89
- package/test/websockets.js +0 -50
- package/test/wpt-tests/README.md +0 -46
- package/test/wpt-tests/chrome-failed-tests.js +0 -42
- package/test/wpt-tests/index.js +0 -96
- package/test/wpt-tests/last-test-results.md +0 -301
- package/test/wpt-tests/package-lock.json +0 -1712
- package/test/wpt-tests/package.json +0 -19
- package/test/wpt-tests/wpt-test-list.js +0 -139
- package/test/wpt-tests/wpt.js +0 -131
- /package/src/{data-channel-wrapper.cpp → cpp/data-channel-wrapper.cpp} +0 -0
- /package/src/{data-channel-wrapper.h → cpp/data-channel-wrapper.h} +0 -0
- /package/src/{main.cpp → cpp/main.cpp} +0 -0
- /package/src/{media-audio-wrapper.cpp → cpp/media-audio-wrapper.cpp} +0 -0
- /package/src/{media-audio-wrapper.h → cpp/media-audio-wrapper.h} +0 -0
- /package/src/{media-direction.cpp → cpp/media-direction.cpp} +0 -0
- /package/src/{media-direction.h → cpp/media-direction.h} +0 -0
- /package/src/{media-rtcpreceivingsession-wrapper.cpp → cpp/media-rtcpreceivingsession-wrapper.cpp} +0 -0
- /package/src/{media-rtcpreceivingsession-wrapper.h → cpp/media-rtcpreceivingsession-wrapper.h} +0 -0
- /package/src/{media-track-wrapper.cpp → cpp/media-track-wrapper.cpp} +0 -0
- /package/src/{media-track-wrapper.h → cpp/media-track-wrapper.h} +0 -0
- /package/src/{media-video-wrapper.cpp → cpp/media-video-wrapper.cpp} +0 -0
- /package/src/{media-video-wrapper.h → cpp/media-video-wrapper.h} +0 -0
- /package/src/{peer-connection-wrapper.cpp → cpp/peer-connection-wrapper.cpp} +0 -0
- /package/src/{peer-connection-wrapper.h → cpp/peer-connection-wrapper.h} +0 -0
- /package/src/{rtc-wrapper.cpp → cpp/rtc-wrapper.cpp} +0 -0
- /package/src/{rtc-wrapper.h → cpp/rtc-wrapper.h} +0 -0
- /package/src/{thread-safe-callback.cpp → cpp/thread-safe-callback.cpp} +0 -0
- /package/src/{thread-safe-callback.h → cpp/thread-safe-callback.h} +0 -0
- /package/src/{web-socket-server-wrapper.cpp → cpp/web-socket-server-wrapper.cpp} +0 -0
- /package/src/{web-socket-server-wrapper.h → cpp/web-socket-server-wrapper.h} +0 -0
- /package/src/{web-socket-wrapper.cpp → cpp/web-socket-wrapper.cpp} +0 -0
- /package/src/{web-socket-wrapper.h → cpp/web-socket-wrapper.h} +0 -0
- /package/{polyfill → src/polyfill}/README.md +0 -0
|
@@ -4,23 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import 'node-domexception';
|
|
6
6
|
|
|
7
|
-
export default class
|
|
8
|
-
#address;
|
|
9
|
-
#candidate;
|
|
10
|
-
#component;
|
|
11
|
-
#foundation;
|
|
12
|
-
#port;
|
|
13
|
-
#priority;
|
|
14
|
-
#protocol;
|
|
15
|
-
#relatedAddress;
|
|
16
|
-
#relatedPort;
|
|
17
|
-
#sdpMLineIndex;
|
|
18
|
-
#sdpMid;
|
|
19
|
-
#tcpType;
|
|
20
|
-
#type;
|
|
21
|
-
#usernameFragment;
|
|
22
|
-
|
|
23
|
-
constructor({ candidate, sdpMLineIndex, sdpMid, usernameFragment }) {
|
|
7
|
+
export default class RTCIceCandidate implements globalThis.RTCIceCandidate {
|
|
8
|
+
#address: string | null;
|
|
9
|
+
#candidate: string;
|
|
10
|
+
#component: globalThis.RTCIceComponent | null;
|
|
11
|
+
#foundation: string | null;
|
|
12
|
+
#port: number | null;
|
|
13
|
+
#priority: number | null;
|
|
14
|
+
#protocol: globalThis.RTCIceProtocol | null;
|
|
15
|
+
#relatedAddress: string | null;
|
|
16
|
+
#relatedPort: number | null;
|
|
17
|
+
#sdpMLineIndex: number | null;
|
|
18
|
+
#sdpMid: string | null;
|
|
19
|
+
#tcpType: globalThis.RTCIceTcpCandidateType | null;
|
|
20
|
+
#type: globalThis.RTCIceCandidateType | null;
|
|
21
|
+
#usernameFragment: string | null;
|
|
22
|
+
|
|
23
|
+
constructor({ candidate, sdpMLineIndex, sdpMid, usernameFragment }: globalThis.RTCIceCandidateInit) {
|
|
24
24
|
if (sdpMLineIndex == null && sdpMid == null)
|
|
25
25
|
throw new TypeError('At least one of sdpMLineIndex or sdpMid must be specified');
|
|
26
26
|
|
|
@@ -33,11 +33,11 @@ export default class _RTCIceCandidate {
|
|
|
33
33
|
const fields = candidate.split(' ');
|
|
34
34
|
this.#foundation = fields[0].replace('candidate:', ''); // remove text candidate:
|
|
35
35
|
this.#component = fields[1] == '1' ? 'rtp' : 'rtcp';
|
|
36
|
-
this.#protocol = fields[2];
|
|
36
|
+
this.#protocol = fields[2] as globalThis.RTCIceProtocol;
|
|
37
37
|
this.#priority = parseInt(fields[3], 10);
|
|
38
38
|
this.#address = fields[4];
|
|
39
39
|
this.#port = parseInt(fields[5], 10);
|
|
40
|
-
this.#type = fields[7];
|
|
40
|
+
this.#type = fields[7] as globalThis.RTCIceCandidateType;
|
|
41
41
|
this.#tcpType = null;
|
|
42
42
|
this.#relatedAddress = null;
|
|
43
43
|
this.#relatedPort = null;
|
|
@@ -52,69 +52,69 @@ export default class _RTCIceCandidate {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (this.#protocol === 'tcp' && field === 'tcptype') {
|
|
55
|
-
this.#tcpType = fields[i + 1];
|
|
55
|
+
this.#tcpType = fields[i + 1] as globalThis.RTCIceTcpCandidateType;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
get address() {
|
|
61
|
+
get address(): string | null {
|
|
62
62
|
return this.#address || null;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
get candidate() {
|
|
65
|
+
get candidate(): string {
|
|
66
66
|
return this.#candidate;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
get component() {
|
|
69
|
+
get component(): globalThis.RTCIceComponent | null {
|
|
70
70
|
return this.#component;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
get foundation() {
|
|
73
|
+
get foundation(): string | null {
|
|
74
74
|
return this.#foundation || null;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
get port() {
|
|
77
|
+
get port(): number | null {
|
|
78
78
|
return this.#port || null;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
get priority() {
|
|
81
|
+
get priority(): number | null {
|
|
82
82
|
return this.#priority || null;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
get protocol() {
|
|
85
|
+
get protocol(): globalThis.RTCIceProtocol | null {
|
|
86
86
|
return this.#protocol || null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
get relatedAddress() {
|
|
89
|
+
get relatedAddress(): string | null {
|
|
90
90
|
return this.#relatedAddress;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
get relatedPort() {
|
|
93
|
+
get relatedPort(): number | null {
|
|
94
94
|
return this.#relatedPort || null;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
get sdpMLineIndex() {
|
|
97
|
+
get sdpMLineIndex(): number | null {
|
|
98
98
|
return this.#sdpMLineIndex;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
get sdpMid() {
|
|
101
|
+
get sdpMid(): string | null {
|
|
102
102
|
return this.#sdpMid;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
get tcpType() {
|
|
105
|
+
get tcpType(): globalThis.RTCIceTcpCandidateType | null {
|
|
106
106
|
return this.#tcpType;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
get type() {
|
|
109
|
+
get type(): globalThis.RTCIceCandidateType | null {
|
|
110
110
|
return this.#type || null;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
get usernameFragment() {
|
|
113
|
+
get usernameFragment(): string | null {
|
|
114
114
|
return this.#usernameFragment;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
toJSON() {
|
|
117
|
+
toJSON(): globalThis.RTCIceCandidateInit {
|
|
118
118
|
return {
|
|
119
119
|
candidate: this.#candidate,
|
|
120
120
|
sdpMLineIndex: this.#sdpMLineIndex,
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import RTCIceCandidate from './RTCIceCandidate';
|
|
3
|
+
import RTCPeerConnection from './RTCPeerConnection';
|
|
2
4
|
|
|
3
|
-
export default class
|
|
4
|
-
#pc = null;
|
|
5
|
+
export default class RTCIceTransport extends EventTarget implements globalThis.RTCIceTransport {
|
|
6
|
+
#pc: RTCPeerConnection = null;
|
|
5
7
|
#extraFunctions = null;
|
|
6
8
|
|
|
7
|
-
ongatheringstatechange = null;
|
|
8
|
-
onselectedcandidatepairchange = null;
|
|
9
|
-
onstatechange = null;
|
|
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;
|
|
10
12
|
|
|
11
|
-
constructor({ pc, extraFunctions }) {
|
|
13
|
+
constructor(init: { pc: RTCPeerConnection, extraFunctions }) {
|
|
12
14
|
super();
|
|
13
|
-
this.#pc = pc;
|
|
14
|
-
this.#extraFunctions = extraFunctions;
|
|
15
|
+
this.#pc = init.pc;
|
|
16
|
+
this.#extraFunctions = init.extraFunctions;
|
|
15
17
|
|
|
16
18
|
// forward peerConnection events
|
|
17
19
|
this.#pc.addEventListener('icegatheringstatechange', () => {
|
|
@@ -30,42 +32,42 @@ export default class _RTCIceTransport extends EventTarget {
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
get component() {
|
|
34
|
-
|
|
35
|
+
get component(): globalThis.RTCIceComponent {
|
|
36
|
+
const cp = this.getSelectedCandidatePair();
|
|
35
37
|
if (!cp) return null;
|
|
36
38
|
return cp.local.component;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
get gatheringState() {
|
|
41
|
+
get gatheringState(): globalThis.RTCIceGatheringState {
|
|
40
42
|
return this.#pc ? this.#pc.iceGatheringState : 'new';
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
get role() {
|
|
45
|
+
get role(): string {
|
|
44
46
|
return this.#pc.localDescription.type == 'offer' ? 'controlling' : 'controlled';
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
get state() {
|
|
49
|
+
get state(): globalThis.RTCIceTransportState {
|
|
48
50
|
return this.#pc ? this.#pc.iceConnectionState : 'new';
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
getLocalCandidates() {
|
|
53
|
+
getLocalCandidates(): RTCIceCandidate[] {
|
|
52
54
|
return this.#pc ? this.#extraFunctions.localCandidates() : [];
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
getLocalParameters() {
|
|
57
|
+
getLocalParameters(): any {
|
|
56
58
|
/** */
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
getRemoteCandidates() {
|
|
61
|
+
getRemoteCandidates(): RTCIceCandidate[] {
|
|
60
62
|
return this.#pc ? this.#extraFunctions.remoteCandidates() : [];
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
getRemoteParameters() {
|
|
65
|
+
getRemoteParameters(): any {
|
|
64
66
|
/** */
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
getSelectedCandidatePair() {
|
|
68
|
-
|
|
69
|
+
getSelectedCandidatePair(): globalThis.RTCIceCandidatePair | null {
|
|
70
|
+
const cp = this.#extraFunctions.selectedCandidatePair();
|
|
69
71
|
if (!cp) return null;
|
|
70
72
|
return {
|
|
71
73
|
local: new RTCIceCandidate({
|