node-datachannel 0.26.0 → 0.28.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/.eslintrc.json +25 -25
- package/.prettierignore +4 -0
- package/.prettierrc +1 -0
- package/API.md +4 -4
- package/BULDING.md +11 -2
- package/CMakeLists.txt +37 -13
- package/README.md +22 -18
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/lib/datachannel-stream.cjs +13 -13
- package/dist/cjs/lib/datachannel-stream.cjs.map +1 -1
- package/dist/cjs/lib/index.cjs +1 -3
- package/dist/cjs/lib/index.cjs.map +1 -1
- package/dist/cjs/lib/websocket-server.cjs.map +1 -1
- package/dist/cjs/lib/websocket.cjs.map +1 -1
- package/dist/cjs/polyfill/Events.cjs +52 -3
- package/dist/cjs/polyfill/Events.cjs.map +1 -1
- package/dist/cjs/polyfill/Exception.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCCertificate.cjs +5 -2
- package/dist/cjs/polyfill/RTCCertificate.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCDataChannel.cjs +27 -19
- package/dist/cjs/polyfill/RTCDataChannel.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCDtlsTransport.cjs +6 -5
- package/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCError.cjs +9 -2
- package/dist/cjs/polyfill/RTCError.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCIceCandidate.cjs +13 -8
- package/dist/cjs/polyfill/RTCIceCandidate.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCIceTransport.cjs +26 -16
- package/dist/cjs/polyfill/RTCIceTransport.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCPeerConnection.cjs +80 -70
- package/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCSctpTransport.cjs +9 -11
- package/dist/cjs/polyfill/RTCSctpTransport.cjs.map +1 -1
- package/dist/cjs/polyfill/RTCSessionDescription.cjs +10 -2
- package/dist/cjs/polyfill/RTCSessionDescription.cjs.map +1 -1
- package/dist/cjs/polyfill/index.cjs.map +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lib/datachannel-stream.mjs.map +1 -1
- package/dist/esm/lib/index.mjs +1 -3
- package/dist/esm/lib/index.mjs.map +1 -1
- package/dist/esm/lib/websocket-server.mjs.map +1 -1
- package/dist/esm/lib/websocket.mjs.map +1 -1
- package/dist/esm/polyfill/Events.mjs +52 -4
- package/dist/esm/polyfill/Events.mjs.map +1 -1
- package/dist/esm/polyfill/Exception.mjs.map +1 -1
- package/dist/esm/polyfill/RTCCertificate.mjs +5 -2
- package/dist/esm/polyfill/RTCCertificate.mjs.map +1 -1
- package/dist/esm/polyfill/RTCDataChannel.mjs +27 -19
- package/dist/esm/polyfill/RTCDataChannel.mjs.map +1 -1
- package/dist/esm/polyfill/RTCDtlsTransport.mjs +6 -5
- package/dist/esm/polyfill/RTCDtlsTransport.mjs.map +1 -1
- package/dist/esm/polyfill/RTCError.mjs +9 -2
- package/dist/esm/polyfill/RTCError.mjs.map +1 -1
- package/dist/esm/polyfill/RTCIceCandidate.mjs +13 -8
- package/dist/esm/polyfill/RTCIceCandidate.mjs.map +1 -1
- package/dist/esm/polyfill/RTCIceTransport.mjs +26 -17
- package/dist/esm/polyfill/RTCIceTransport.mjs.map +1 -1
- package/dist/esm/polyfill/RTCPeerConnection.mjs +80 -70
- package/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -1
- package/dist/esm/polyfill/RTCSctpTransport.mjs +9 -11
- package/dist/esm/polyfill/RTCSctpTransport.mjs.map +1 -1
- package/dist/esm/polyfill/RTCSessionDescription.mjs +10 -2
- package/dist/esm/polyfill/RTCSessionDescription.mjs.map +1 -1
- package/dist/esm/polyfill/index.mjs.map +1 -1
- package/dist/types/lib/index.d.ts +5 -2
- package/dist/types/lib/types.d.ts +6 -6
- package/dist/types/polyfill/Events.d.ts +3 -3
- package/dist/types/polyfill/RTCCertificate.d.ts +1 -0
- package/dist/types/polyfill/RTCDataChannel.d.ts +6 -6
- package/dist/types/polyfill/RTCDtlsTransport.d.ts +4 -6
- package/dist/types/polyfill/RTCError.d.ts +1 -0
- package/dist/types/polyfill/RTCIceCandidate.d.ts +1 -1
- package/dist/types/polyfill/RTCIceTransport.d.ts +16 -10
- package/dist/types/polyfill/RTCPeerConnection.d.ts +29 -22
- package/dist/types/polyfill/RTCSctpTransport.d.ts +2 -4
- package/dist/types/polyfill/RTCSessionDescription.d.ts +1 -0
- package/jest.config.ts +8 -8
- package/package.json +114 -112
- package/rollup.config.mjs +1 -1
- package/src/cpp/data-channel-wrapper.cpp +11 -0
- 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/index.ts +0 -1
- package/src/lib/datachannel-stream.ts +83 -84
- package/src/lib/index.ts +165 -139
- package/src/lib/types.ts +97 -72
- package/src/lib/websocket-server.ts +25 -25
- package/src/lib/websocket.ts +19 -19
- package/src/polyfill/Events.ts +65 -19
- package/src/polyfill/Exception.ts +24 -24
- package/src/polyfill/README.md +8 -8
- package/src/polyfill/RTCCertificate.ts +16 -12
- package/src/polyfill/RTCDataChannel.ts +198 -192
- package/src/polyfill/RTCDtlsTransport.ts +38 -39
- package/src/polyfill/RTCError.ts +63 -56
- package/src/polyfill/RTCIceCandidate.ts +120 -116
- package/src/polyfill/RTCIceTransport.ts +71 -64
- package/src/polyfill/RTCPeerConnection.ts +436 -420
- package/src/polyfill/RTCSctpTransport.ts +43 -47
- package/src/polyfill/RTCSessionDescription.ts +26 -17
- package/src/polyfill/index.ts +22 -22
|
@@ -3,53 +3,49 @@ import RTCDtlsTransport from './RTCDtlsTransport';
|
|
|
3
3
|
import RTCPeerConnection from './RTCPeerConnection';
|
|
4
4
|
|
|
5
5
|
export default class RTCSctpTransport extends EventTarget implements globalThis.RTCSctpTransport {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
6
|
+
#pc: RTCPeerConnection = null;
|
|
7
|
+
#transport: globalThis.RTCDtlsTransport = null;
|
|
8
|
+
|
|
9
|
+
onstatechange: globalThis.RTCSctpTransport['onstatechange'] = null;
|
|
10
|
+
|
|
11
|
+
constructor(initial: { pc: RTCPeerConnection }) {
|
|
12
|
+
super();
|
|
13
|
+
this.#pc = initial.pc;
|
|
14
|
+
|
|
15
|
+
this.#transport = new RTCDtlsTransport({
|
|
16
|
+
pc: initial.pc
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
this.#pc.addEventListener('connectionstatechange', () => {
|
|
20
|
+
const e = new Event('statechange');
|
|
21
|
+
this.dispatchEvent(e);
|
|
22
|
+
this.onstatechange?.(e);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get maxChannels(): number | null {
|
|
27
|
+
if (this.state !== 'connected') return null;
|
|
28
|
+
return this.#pc.ext_maxDataChannelId;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get maxMessageSize(): number {
|
|
32
|
+
if (this.state !== 'connected') return null;
|
|
33
|
+
return this.#pc?.ext_maxMessageSize ?? 65536;;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get state(): globalThis.RTCSctpTransportState {
|
|
37
|
+
// reduce state from new, connecting, connected, disconnected, failed, closed, unknown
|
|
38
|
+
// to RTCSctpTransport states connecting, connected, closed
|
|
39
|
+
let state = this.#pc.connectionState;
|
|
40
|
+
if (state === 'new' || state === 'connecting') {
|
|
41
|
+
state = 'connecting';
|
|
42
|
+
} else if (state === 'disconnected' || state === 'failed' || state === 'closed') {
|
|
43
|
+
state = 'closed';
|
|
38
44
|
}
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let state = this.#pc.connectionState;
|
|
44
|
-
if (state === 'new' || state === 'connecting') {
|
|
45
|
-
state = 'connecting';
|
|
46
|
-
} else if (state === 'disconnected' || state === 'failed' || state === 'closed') {
|
|
47
|
-
state = 'closed';
|
|
48
|
-
}
|
|
49
|
-
return state;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get transport(): RTCDtlsTransport {
|
|
53
|
-
return this.#transport;
|
|
54
|
-
}
|
|
48
|
+
get transport(): globalThis.RTCDtlsTransport {
|
|
49
|
+
return this.#transport;
|
|
50
|
+
}
|
|
55
51
|
}
|
|
@@ -7,26 +7,35 @@
|
|
|
7
7
|
// };
|
|
8
8
|
|
|
9
9
|
export default class RTCSessionDescription implements globalThis.RTCSessionDescriptionInit {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
#type: globalThis.RTCSdpType;
|
|
11
|
+
#sdp: string;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
constructor(init: globalThis.RTCSessionDescriptionInit) {
|
|
14
|
+
this.#type = init?.type;
|
|
15
|
+
this.#sdp = init?.sdp ?? '';
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
get type(): globalThis.RTCSdpType {
|
|
19
|
+
return this.#type;
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
set type(type) {
|
|
23
|
+
if (type !== 'offer' && type !== 'answer' && type !== 'pranswer' && type !== 'rollback') {
|
|
24
|
+
throw new TypeError(
|
|
25
|
+
`Failed to set the 'type' property on 'RTCSessionDescription': The provided value '${type}' is not a valid enum value of type RTCSdpType.`,
|
|
26
|
+
);
|
|
24
27
|
}
|
|
28
|
+
this.#type = type;
|
|
29
|
+
}
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
get sdp(): string {
|
|
32
|
+
return this.#sdp;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
toJSON(): globalThis.RTCSessionDescriptionInit {
|
|
36
|
+
return {
|
|
37
|
+
sdp: this.#sdp,
|
|
38
|
+
type: this.#type,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
32
41
|
}
|
package/src/polyfill/index.ts
CHANGED
|
@@ -10,29 +10,29 @@ import { RTCDataChannelEvent, RTCPeerConnectionIceEvent } from './Events';
|
|
|
10
10
|
import RTCError from './RTCError';
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
RTCCertificate,
|
|
14
|
+
RTCDataChannel,
|
|
15
|
+
RTCDtlsTransport,
|
|
16
|
+
RTCIceCandidate,
|
|
17
|
+
RTCIceTransport,
|
|
18
|
+
RTCPeerConnection,
|
|
19
|
+
RTCSctpTransport,
|
|
20
|
+
RTCSessionDescription,
|
|
21
|
+
RTCDataChannelEvent,
|
|
22
|
+
RTCPeerConnectionIceEvent,
|
|
23
|
+
RTCError,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export default {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
RTCCertificate,
|
|
28
|
+
RTCDataChannel,
|
|
29
|
+
RTCDtlsTransport,
|
|
30
|
+
RTCIceCandidate,
|
|
31
|
+
RTCIceTransport,
|
|
32
|
+
RTCPeerConnection,
|
|
33
|
+
RTCSctpTransport,
|
|
34
|
+
RTCSessionDescription,
|
|
35
|
+
RTCDataChannelEvent,
|
|
36
|
+
RTCPeerConnectionIceEvent,
|
|
37
|
+
RTCError,
|
|
38
38
|
};
|