node-datachannel 0.26.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.
Files changed (41) hide show
  1. package/CMakeLists.txt +29 -10
  2. package/dist/cjs/lib/index.cjs +1 -3
  3. package/dist/cjs/lib/index.cjs.map +1 -1
  4. package/dist/cjs/polyfill/Events.cjs.map +1 -1
  5. package/dist/cjs/polyfill/RTCDataChannel.cjs.map +1 -1
  6. package/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +1 -1
  7. package/dist/cjs/polyfill/RTCError.cjs.map +1 -1
  8. package/dist/cjs/polyfill/RTCIceTransport.cjs.map +1 -1
  9. package/dist/cjs/polyfill/RTCPeerConnection.cjs +1 -1
  10. package/dist/cjs/polyfill/RTCPeerConnection.cjs.map +1 -1
  11. package/dist/cjs/polyfill/RTCSctpTransport.cjs.map +1 -1
  12. package/dist/esm/lib/index.mjs +1 -3
  13. package/dist/esm/lib/index.mjs.map +1 -1
  14. package/dist/esm/polyfill/Events.mjs.map +1 -1
  15. package/dist/esm/polyfill/RTCDataChannel.mjs.map +1 -1
  16. package/dist/esm/polyfill/RTCDtlsTransport.mjs.map +1 -1
  17. package/dist/esm/polyfill/RTCError.mjs.map +1 -1
  18. package/dist/esm/polyfill/RTCIceTransport.mjs.map +1 -1
  19. package/dist/esm/polyfill/RTCPeerConnection.mjs +1 -1
  20. package/dist/esm/polyfill/RTCPeerConnection.mjs.map +1 -1
  21. package/dist/esm/polyfill/RTCSctpTransport.mjs.map +1 -1
  22. package/dist/types/lib/index.d.ts +5 -2
  23. package/dist/types/polyfill/Events.d.ts +3 -6
  24. package/dist/types/polyfill/RTCDataChannel.d.ts +6 -6
  25. package/dist/types/polyfill/RTCDtlsTransport.d.ts +5 -8
  26. package/dist/types/polyfill/RTCIceTransport.d.ts +6 -9
  27. package/dist/types/polyfill/RTCPeerConnection.d.ts +18 -22
  28. package/dist/types/polyfill/RTCSctpTransport.d.ts +3 -6
  29. package/package.json +112 -112
  30. package/src/cpp/main.cpp +14 -0
  31. package/src/cpp/peer-connection-wrapper.cpp +9 -1
  32. package/src/cpp/peer-connection-wrapper.h +5 -1
  33. package/src/cpp/rtc-wrapper.cpp +18 -0
  34. package/src/lib/index.ts +5 -2
  35. package/src/polyfill/Events.ts +6 -10
  36. package/src/polyfill/RTCDataChannel.ts +7 -7
  37. package/src/polyfill/RTCDtlsTransport.ts +6 -7
  38. package/src/polyfill/RTCError.ts +1 -1
  39. package/src/polyfill/RTCIceTransport.ts +7 -8
  40. package/src/polyfill/RTCPeerConnection.ts +30 -30
  41. package/src/polyfill/RTCSctpTransport.ts +5 -6
@@ -23,27 +23,27 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
23
23
  #peerConnection: PeerConnection;
24
24
  #localOffer: any;
25
25
  #localAnswer: any;
26
- #dataChannels: Set<RTCDataChannel>;
26
+ #dataChannels: Set<globalThis.RTCDataChannel>;
27
27
  #dataChannelsClosed = 0;
28
- #config: RTCConfiguration;
28
+ #config: globalThis.RTCConfiguration;
29
29
  #canTrickleIceCandidates: boolean | null;
30
- #sctp: RTCSctpTransport;
30
+ #sctp: globalThis.RTCSctpTransport;
31
31
 
32
- #localCandidates: RTCIceCandidate[] = [];
33
- #remoteCandidates: RTCIceCandidate[] = [];
32
+ #localCandidates: globalThis.RTCIceCandidate[] = [];
33
+ #remoteCandidates: globalThis.RTCIceCandidate[] = [];
34
34
 
35
35
  // events
36
- onconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
37
- ondatachannel: ((this: RTCPeerConnection, ev: RTCDataChannelEvent) => any) | null;
38
- onicecandidate: ((this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any) | null;
39
- onicecandidateerror: ((this: RTCPeerConnection, ev: Event) => any) | null;
40
- oniceconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
41
- onicegatheringstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
42
- onnegotiationneeded: ((this: RTCPeerConnection, ev: Event) => any) | null;
43
- onsignalingstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null;
44
- ontrack: ((this: RTCPeerConnection, ev: globalThis.RTCTrackEvent) => any) | null;
45
-
46
- private _checkConfiguration(config: RTCConfiguration): void {
36
+ onconnectionstatechange: ((this: globalThis.RTCPeerConnection, ev: Event) => any) | null;
37
+ ondatachannel: ((this: globalThis.RTCPeerConnection, ev: globalThis.RTCDataChannelEvent) => any) | null;
38
+ onicecandidate: ((this: globalThis.RTCPeerConnection, ev: globalThis.RTCPeerConnectionIceEvent) => any) | null;
39
+ onicecandidateerror: ((this: globalThis.RTCPeerConnection, ev: Event) => any) | null;
40
+ oniceconnectionstatechange: ((this: globalThis.RTCPeerConnection, ev: Event) => any) | null;
41
+ onicegatheringstatechange: ((this: globalThis.RTCPeerConnection, ev: Event) => any) | null;
42
+ onnegotiationneeded: ((this: globalThis.RTCPeerConnection, ev: Event) => any) | null;
43
+ onsignalingstatechange: ((this: globalThis.RTCPeerConnection, ev: Event) => any) | null;
44
+ ontrack: ((this: globalThis.RTCPeerConnection, ev: globalThis.RTCTrackEvent) => any) | null;
45
+
46
+ private _checkConfiguration(config: globalThis.RTCConfiguration): void {
47
47
  if (config && config.iceServers === undefined) config.iceServers = [];
48
48
  if (config && config.iceTransportPolicy === undefined) config.iceTransportPolicy = 'all';
49
49
 
@@ -103,7 +103,7 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
103
103
  throw new TypeError('IceTransportPolicy must be either "all" or "relay"');
104
104
  }
105
105
 
106
- setConfiguration(config: RTCConfiguration): void {
106
+ setConfiguration(config: globalThis.RTCConfiguration): void {
107
107
  this._checkConfiguration(config);
108
108
  this.#config = config;
109
109
  }
@@ -122,7 +122,7 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
122
122
 
123
123
  try {
124
124
  const peerIdentity = (config as any)?.peerIdentity ?? `peer-${getRandomString(7)}`;
125
- this.#peerConnection = config.peerConnection ?? new PeerConnection(peerIdentity,
125
+ this.#peerConnection = config?.peerConnection ?? new PeerConnection(peerIdentity,
126
126
  {
127
127
  ...config,
128
128
  iceServers:
@@ -203,10 +203,10 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
203
203
  if (this.onicegatheringstatechange) this.onicegatheringstatechange(e);
204
204
  });
205
205
  this.addEventListener('datachannel', (e) => {
206
- if (this.ondatachannel) this.ondatachannel(e as RTCDataChannelEvent);
206
+ if (this.ondatachannel) this.ondatachannel(e as globalThis.RTCDataChannelEvent);
207
207
  });
208
208
  this.addEventListener('icecandidate', (e) => {
209
- if (this.onicecandidate) this.onicecandidate(e as RTCPeerConnectionIceEvent);
209
+ if (this.onicecandidate) this.onicecandidate(e as globalThis.RTCPeerConnectionIceEvent);
210
210
  });
211
211
 
212
212
  this.#sctp = new RTCSctpTransport({
@@ -218,10 +218,10 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
218
218
  maxMessageSize: (): number => {
219
219
  return this.#peerConnection.maxMessageSize();
220
220
  },
221
- localCandidates: (): RTCIceCandidate[] => {
221
+ localCandidates: (): globalThis.RTCIceCandidate[] => {
222
222
  return this.#localCandidates;
223
223
  },
224
- remoteCandidates: (): RTCIceCandidate[] => {
224
+ remoteCandidates: (): globalThis.RTCIceCandidate[] => {
225
225
  return this.#remoteCandidates;
226
226
  },
227
227
  selectedCandidatePair: (): { local: SelectedCandidateInfo; remote: SelectedCandidateInfo } | null => {
@@ -251,31 +251,31 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
251
251
  return this.#peerConnection.gatheringState();
252
252
  }
253
253
 
254
- get currentLocalDescription(): RTCSessionDescription {
254
+ get currentLocalDescription(): globalThis.RTCSessionDescription {
255
255
  return new RTCSessionDescription(this.#peerConnection.localDescription() as any);
256
256
  }
257
257
 
258
- get currentRemoteDescription(): RTCSessionDescription {
258
+ get currentRemoteDescription(): globalThis.RTCSessionDescription {
259
259
  return new RTCSessionDescription(this.#peerConnection.remoteDescription() as any);
260
260
  }
261
261
 
262
- get localDescription(): RTCSessionDescription {
262
+ get localDescription(): globalThis.RTCSessionDescription {
263
263
  return new RTCSessionDescription(this.#peerConnection.localDescription() as any);
264
264
  }
265
265
 
266
- get pendingLocalDescription(): RTCSessionDescription {
266
+ get pendingLocalDescription(): globalThis.RTCSessionDescription {
267
267
  return new RTCSessionDescription(this.#peerConnection.localDescription() as any);
268
268
  }
269
269
 
270
- get pendingRemoteDescription(): RTCSessionDescription {
270
+ get pendingRemoteDescription():globalThis.RTCSessionDescription {
271
271
  return new RTCSessionDescription(this.#peerConnection.remoteDescription() as any);
272
272
  }
273
273
 
274
- get remoteDescription(): RTCSessionDescription {
274
+ get remoteDescription(): globalThis.RTCSessionDescription {
275
275
  return new RTCSessionDescription(this.#peerConnection.remoteDescription() as any);
276
276
  }
277
277
 
278
- get sctp(): RTCSctpTransport {
278
+ get sctp(): globalThis.RTCSctpTransport {
279
279
  return this.#sctp;
280
280
  }
281
281
 
@@ -350,7 +350,7 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
350
350
  }
351
351
 
352
352
 
353
- createDataChannel(label, opts = {}): RTCDataChannel {
353
+ createDataChannel(label, opts = {}): globalThis.RTCDataChannel {
354
354
  const channel = this.#peerConnection.createDataChannel(label, opts);
355
355
  const dataChannel = new RTCDataChannel(channel, opts);
356
356
 
@@ -1,15 +1,14 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import RTCDtlsTransport from './RTCDtlsTransport';
3
- import RTCPeerConnection from './RTCPeerConnection';
4
3
 
5
4
  export default class RTCSctpTransport extends EventTarget implements globalThis.RTCSctpTransport {
6
- #pc: RTCPeerConnection = null;
5
+ #pc: globalThis.RTCPeerConnection = null;
7
6
  #extraFunctions = null;
8
- #transport: RTCDtlsTransport = null;
7
+ #transport: globalThis.RTCDtlsTransport = null;
9
8
 
10
- onstatechange: ((this: RTCSctpTransport, ev: Event) => any) | null = null;
9
+ onstatechange: ((this: globalThis.RTCSctpTransport, ev: Event) => any) | null = null;
11
10
 
12
- constructor(initial: { pc: RTCPeerConnection, extraFunctions }) {
11
+ constructor(initial: { pc: globalThis.RTCPeerConnection, extraFunctions }) {
13
12
  super();
14
13
  this.#pc = initial.pc;
15
14
  this.#extraFunctions = initial.extraFunctions;
@@ -49,7 +48,7 @@ export default class RTCSctpTransport extends EventTarget implements globalThis.
49
48
  return state;
50
49
  }
51
50
 
52
- get transport(): RTCDtlsTransport {
51
+ get transport(): globalThis.RTCDtlsTransport {
53
52
  return this.#transport;
54
53
  }
55
54
  }