werift 0.19.9 → 0.20.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.
Files changed (139) hide show
  1. package/lib/common/src/event.d.ts +45 -0
  2. package/lib/common/src/event.js +232 -0
  3. package/lib/common/src/event.js.map +1 -0
  4. package/lib/common/src/index.d.ts +1 -0
  5. package/lib/common/src/index.js +1 -0
  6. package/lib/common/src/index.js.map +1 -1
  7. package/lib/dtls/src/flight/client/flight5.js +6 -1
  8. package/lib/dtls/src/flight/client/flight5.js.map +1 -1
  9. package/lib/dtls/src/imports/common.d.ts +1 -0
  10. package/lib/dtls/src/imports/common.js +18 -0
  11. package/lib/dtls/src/imports/common.js.map +1 -0
  12. package/lib/dtls/src/socket.d.ts +1 -1
  13. package/lib/dtls/src/socket.js +5 -5
  14. package/lib/dtls/src/socket.js.map +1 -1
  15. package/lib/ice/src/candidate.d.ts +1 -1
  16. package/lib/ice/src/candidate.js +2 -1
  17. package/lib/ice/src/candidate.js.map +1 -1
  18. package/lib/ice/src/helper.js +2 -2
  19. package/lib/ice/src/helper.js.map +1 -1
  20. package/lib/ice/src/ice.d.ts +10 -5
  21. package/lib/ice/src/ice.js +46 -16
  22. package/lib/ice/src/ice.js.map +1 -1
  23. package/lib/ice/src/imports/common.d.ts +1 -0
  24. package/lib/ice/src/imports/common.js +18 -0
  25. package/lib/ice/src/imports/common.js.map +1 -0
  26. package/lib/ice/src/index.d.ts +4 -0
  27. package/lib/ice/src/index.js +4 -0
  28. package/lib/ice/src/index.js.map +1 -1
  29. package/lib/ice/src/stun/message.d.ts +1 -0
  30. package/lib/ice/src/stun/message.js +16 -6
  31. package/lib/ice/src/stun/message.js.map +1 -1
  32. package/lib/ice/src/stun/protocol.d.ts +3 -2
  33. package/lib/ice/src/stun/protocol.js +13 -7
  34. package/lib/ice/src/stun/protocol.js.map +1 -1
  35. package/lib/ice/src/stun/transaction.js +4 -3
  36. package/lib/ice/src/stun/transaction.js.map +1 -1
  37. package/lib/ice/src/transport.d.ts +21 -4
  38. package/lib/ice/src/transport.js +115 -7
  39. package/lib/ice/src/transport.js.map +1 -1
  40. package/lib/ice/src/turn/protocol.d.ts +52 -36
  41. package/lib/ice/src/turn/protocol.js +183 -76
  42. package/lib/ice/src/turn/protocol.js.map +1 -1
  43. package/lib/ice/src/types/model.d.ts +5 -5
  44. package/lib/ice/src/types/model.js.map +1 -1
  45. package/lib/ice/src/utils.d.ts +1 -0
  46. package/lib/ice/src/utils.js +15 -16
  47. package/lib/ice/src/utils.js.map +1 -1
  48. package/lib/rtp/src/extra/container/mp4/container.d.ts +1 -1
  49. package/lib/rtp/src/extra/container/mp4/container.js +2 -5
  50. package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
  51. package/lib/rtp/src/extra/processor/depacketizer.d.ts +1 -1
  52. package/lib/rtp/src/extra/processor/depacketizer.js +2 -2
  53. package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
  54. package/lib/rtp/src/extra/processor/mp4.d.ts +1 -1
  55. package/lib/rtp/src/extra/processor/mp4.js +2 -5
  56. package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
  57. package/lib/rtp/src/extra/processor/nack.d.ts +1 -1
  58. package/lib/rtp/src/extra/processor/nack.js +3 -3
  59. package/lib/rtp/src/extra/processor/nack.js.map +1 -1
  60. package/lib/rtp/src/extra/processor/rtcpCallback.d.ts +1 -1
  61. package/lib/rtp/src/extra/processor/rtcpCallback.js +2 -5
  62. package/lib/rtp/src/extra/processor/rtcpCallback.js.map +1 -1
  63. package/lib/rtp/src/extra/processor/rtpCallback.d.ts +1 -1
  64. package/lib/rtp/src/extra/processor/rtpCallback.js +2 -5
  65. package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
  66. package/lib/rtp/src/extra/processor/webm.d.ts +1 -1
  67. package/lib/rtp/src/extra/processor/webm.js +2 -5
  68. package/lib/rtp/src/extra/processor/webm.js.map +1 -1
  69. package/lib/rtp/src/imports/common.d.ts +1 -0
  70. package/lib/rtp/src/imports/common.js +18 -0
  71. package/lib/rtp/src/imports/common.js.map +1 -0
  72. package/lib/sctp/src/helper.js +2 -5
  73. package/lib/sctp/src/helper.js.map +1 -1
  74. package/lib/sctp/src/imports/common.d.ts +1 -0
  75. package/lib/sctp/src/imports/common.js +18 -0
  76. package/lib/sctp/src/imports/common.js.map +1 -0
  77. package/lib/sctp/src/sctp.d.ts +1 -1
  78. package/lib/sctp/src/sctp.js +3 -3
  79. package/lib/sctp/src/sctp.js.map +1 -1
  80. package/lib/webrtc/src/dataChannel.d.ts +1 -1
  81. package/lib/webrtc/src/dataChannel.js +5 -5
  82. package/lib/webrtc/src/dataChannel.js.map +1 -1
  83. package/lib/webrtc/src/imports/common.d.ts +1 -0
  84. package/lib/webrtc/src/imports/common.js +18 -0
  85. package/lib/webrtc/src/imports/common.js.map +1 -0
  86. package/lib/webrtc/src/media/receiver/nack.d.ts +1 -1
  87. package/lib/webrtc/src/media/receiver/nack.js +2 -2
  88. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  89. package/lib/webrtc/src/media/rtpReceiver.d.ts +2 -2
  90. package/lib/webrtc/src/media/rtpReceiver.js +2 -5
  91. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  92. package/lib/webrtc/src/media/rtpSender.d.ts +1 -1
  93. package/lib/webrtc/src/media/rtpSender.js +5 -5
  94. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  95. package/lib/webrtc/src/media/rtpTransceiver.d.ts +1 -1
  96. package/lib/webrtc/src/media/rtpTransceiver.js +2 -5
  97. package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
  98. package/lib/webrtc/src/media/sender/senderBWE.d.ts +1 -1
  99. package/lib/webrtc/src/media/sender/senderBWE.js +4 -7
  100. package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
  101. package/lib/webrtc/src/media/track.d.ts +1 -1
  102. package/lib/webrtc/src/media/track.js +4 -7
  103. package/lib/webrtc/src/media/track.js.map +1 -1
  104. package/lib/webrtc/src/nonstandard/recorder/index.d.ts +2 -1
  105. package/lib/webrtc/src/nonstandard/recorder/index.js +2 -5
  106. package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
  107. package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +1 -1
  108. package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
  109. package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +1 -1
  110. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +2 -2
  111. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
  112. package/lib/webrtc/src/peerConnection.d.ts +9 -6
  113. package/lib/webrtc/src/peerConnection.js +31 -18
  114. package/lib/webrtc/src/peerConnection.js.map +1 -1
  115. package/lib/webrtc/src/transport/dtls.d.ts +1 -1
  116. package/lib/webrtc/src/transport/dtls.js +12 -8
  117. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  118. package/lib/webrtc/src/transport/ice.d.ts +3 -3
  119. package/lib/webrtc/src/transport/ice.js +14 -8
  120. package/lib/webrtc/src/transport/ice.js.map +1 -1
  121. package/lib/webrtc/src/transport/sctp.d.ts +1 -1
  122. package/lib/webrtc/src/transport/sctp.js +2 -2
  123. package/lib/webrtc/src/transport/sctp.js.map +1 -1
  124. package/package.json +1 -1
  125. package/src/dataChannel.ts +1 -1
  126. package/src/imports/common.ts +1 -0
  127. package/src/media/receiver/nack.ts +1 -1
  128. package/src/media/rtpReceiver.ts +1 -1
  129. package/src/media/rtpSender.ts +1 -1
  130. package/src/media/rtpTransceiver.ts +1 -1
  131. package/src/media/sender/senderBWE.ts +1 -1
  132. package/src/media/track.ts +1 -1
  133. package/src/nonstandard/recorder/index.ts +3 -1
  134. package/src/nonstandard/recorder/writer/index.ts +1 -1
  135. package/src/nonstandard/recorder/writer/webm.ts +1 -1
  136. package/src/peerConnection.ts +30 -15
  137. package/src/transport/dtls.ts +11 -5
  138. package/src/transport/ice.ts +14 -8
  139. package/src/transport/sctp.ts +1 -1
@@ -1,8 +1,8 @@
1
1
  import { Certificate, PrivateKey } from "@fidm/x509";
2
2
  import debug from "debug";
3
- import Event from "rx.mini";
4
3
  import { setTimeout } from "timers/promises";
5
4
  import { v4 } from "uuid";
5
+ import { Event } from "../imports/common";
6
6
 
7
7
  import {
8
8
  DtlsClient,
@@ -106,8 +106,12 @@ export class RTCDtlsTransport {
106
106
  }
107
107
 
108
108
  async start() {
109
- if (this.state !== "new") throw new Error();
110
- if (this.remoteParameters?.fingerprints.length === 0) throw new Error();
109
+ if (this.state !== "new") {
110
+ throw new Error("state must be new");
111
+ }
112
+ if (this.remoteParameters?.fingerprints.length === 0) {
113
+ throw new Error("remote fingerprint not exist");
114
+ }
111
115
 
112
116
  if (this.role === "auto") {
113
117
  if (this.iceTransport.role === "controlling") {
@@ -119,7 +123,7 @@ export class RTCDtlsTransport {
119
123
 
120
124
  this.setState("connecting");
121
125
 
122
- await new Promise<void>(async (r) => {
126
+ await new Promise<void>(async (r, f) => {
123
127
  if (this.role === "server") {
124
128
  this.dtls = new DtlsServer({
125
129
  cert: this.localCertificate?.certPem,
@@ -153,9 +157,10 @@ export class RTCDtlsTransport {
153
157
  this.setState("closed");
154
158
  });
155
159
  this.dtls.onConnect.once(r);
156
- this.dtls.onError.subscribe((error) => {
160
+ this.dtls.onError.once((error) => {
157
161
  this.setState("failed");
158
162
  log("dtls failed", error);
163
+ f(error);
159
164
  });
160
165
 
161
166
  if (this.dtls instanceof DtlsClient) {
@@ -163,6 +168,7 @@ export class RTCDtlsTransport {
163
168
  this.dtls.connect().catch((error) => {
164
169
  this.setState("failed");
165
170
  log("dtls connect failed", error);
171
+ f(error);
166
172
  });
167
173
  }
168
174
  });
@@ -1,6 +1,6 @@
1
1
  import debug from "debug";
2
- import Event from "rx.mini";
3
2
  import { v4 } from "uuid";
3
+ import { Event } from "../imports/common";
4
4
 
5
5
  import { Candidate, Connection, type IceOptions } from "../../../ice/src";
6
6
  import { candidateFromSdp, candidateToSdp } from "../sdp";
@@ -71,11 +71,16 @@ export class RTCIceTransport {
71
71
  }
72
72
 
73
73
  async start() {
74
- if (this.state === "closed") throw new Error("RTCIceTransport is closed");
75
- if (!this.connection.remotePassword || !this.connection.remoteUsername)
74
+ if (this.state === "closed") {
75
+ throw new Error("RTCIceTransport is closed");
76
+ }
77
+ if (!this.connection.remotePassword || !this.connection.remoteUsername) {
76
78
  throw new Error("remoteParams missing");
79
+ }
77
80
 
78
- if (this.waitStart) await this.waitStart.asPromise();
81
+ if (this.waitStart) {
82
+ await this.waitStart.asPromise();
83
+ }
79
84
  this.waitStart = new Event();
80
85
 
81
86
  this.setState("checking");
@@ -113,7 +118,7 @@ export const IceGathererStates = ["new", "gathering", "complete"] as const;
113
118
  export type IceGathererState = (typeof IceGathererStates)[number];
114
119
 
115
120
  export class RTCIceGatherer {
116
- onIceCandidate: (candidate: IceCandidate) => void = () => {};
121
+ onIceCandidate: (candidate: IceCandidate | undefined) => void = () => {};
117
122
  gatheringState: IceGathererState = "new";
118
123
 
119
124
  readonly onGatheringStateChange = new Event<[IceGathererState]>();
@@ -126,9 +131,10 @@ export class RTCIceGatherer {
126
131
  async gather() {
127
132
  if (this.gatheringState === "new") {
128
133
  this.setState("gathering");
129
- await this.connection.gatherCandidates((candidate) =>
130
- this.onIceCandidate(candidateFromIce(candidate)),
131
- );
134
+ await this.connection.gatherCandidates((candidate) => {
135
+ this.onIceCandidate(candidateFromIce(candidate));
136
+ });
137
+ this.onIceCandidate(undefined);
132
138
  this.setState("complete");
133
139
  }
134
140
  }
@@ -1,7 +1,7 @@
1
1
  import { jspack } from "@shinyoshiaki/jspack";
2
2
  import debug from "debug";
3
- import { Event } from "rx.mini";
4
3
  import * as uuid from "uuid";
4
+ import { Event } from "../imports/common";
5
5
 
6
6
  import { SCTP, SCTP_STATE, type Transport } from "../../../sctp/src";
7
7
  import {