lecodes-sdk 2.2.8 → 2.2.9

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/package.json CHANGED
@@ -45,7 +45,7 @@
45
45
  "marcidb-embedded": "^0.15.0",
46
46
  "sharp": "^0.35.2"
47
47
  },
48
- "version": "2.2.8",
48
+ "version": "2.2.9",
49
49
  "files": [
50
50
  "src",
51
51
  "dist",
@@ -509,6 +509,9 @@ export class RTCPeerConnection extends RTCEventTarget {
509
509
  * after the promise, and the app's signaling expects the description first. */
510
510
  private _settingLocal = 0
511
511
  private _heldCandidates: (RTCIceCandidate | null)[] = []
512
+ /** After the app's close(): what the host still says of the dying session is not an event (the
513
+ * browser fires none for close()). */
514
+ private _closedByApp = false
512
515
 
513
516
  onnegotiationneeded: RTCEventListener<RTCEvent<RTCPeerConnection>> | null = null
514
517
  onicecandidate: RTCEventListener<RTCPeerConnectionIceEvent> | null = null
@@ -524,33 +527,34 @@ export class RTCPeerConnection extends RTCEventTarget {
524
527
  if (!RtcPeerConnectionBase.supports(PC_NAME)) throw unsupported("RTCPeerConnection", PC_NAME, "service")
525
528
  this._configuration = configuration
526
529
  const s = this._s = new RtcPeerConnectionBase(configurationWire(configuration))
527
- s.on("negotiationNeeded", () => this._dispatch({ type: "negotiationneeded" }))
528
- s.on("iceCandidate", ({ candidate }) => {
530
+ const on: typeof s.on = (event, callback) => s.on(event, ((payload?: any) => { if (!this._closedByApp) (callback as any)(payload) }) as any)
531
+ on("negotiationNeeded", () => this._dispatch({ type: "negotiationneeded" }))
532
+ on("iceCandidate", ({ candidate }) => {
529
533
  const ice = candidate ? new RTCIceCandidate(candidate) : null
530
534
  if (this._settingLocal > 0) this._heldCandidates.push(ice)
531
535
  else this._dispatch({ type: "icecandidate", candidate: ice })
532
536
  })
533
- s.on("signalingStateChange", ({ state }) => { this._signaling = state; this._dispatch({ type: "signalingstatechange" }) })
534
- s.on("iceGatheringStateChange", ({ state }) => { this._gathering = state; this._dispatch({ type: "icegatheringstatechange" }) })
535
- s.on("iceConnectionStateChange", ({ state }) => { this._ice = state; this._dispatch({ type: "iceconnectionstatechange" }) })
536
- s.on("connectionStateChange", ({ state }) => { this._connection = state; this._dispatch({ type: "connectionstatechange" }) })
537
- s.on("track", ({ track, streamIds, transceiverId }) => { this._onTrack(track, streamIds, transceiverId).catch(() => {}) })
538
- s.on("trackMute", ({ trackId, muted }) => tracks.get(trackId)?._setMuted(muted))
539
- s.on("trackEnded", ({ trackId }) => tracks.get(trackId)?._ended())
540
- s.on("dataChannel", info => {
537
+ on("signalingStateChange", ({ state }) => { this._signaling = state; this._dispatch({ type: "signalingstatechange" }) })
538
+ on("iceGatheringStateChange", ({ state }) => { this._gathering = state; this._dispatch({ type: "icegatheringstatechange" }) })
539
+ on("iceConnectionStateChange", ({ state }) => { this._ice = state; this._dispatch({ type: "iceconnectionstatechange" }) })
540
+ on("connectionStateChange", ({ state }) => { this._connection = state; this._dispatch({ type: "connectionstatechange" }) })
541
+ on("track", ({ track, streamIds, transceiverId }) => { this._onTrack(track, streamIds, transceiverId).catch(() => {}) })
542
+ on("trackMute", ({ trackId, muted }) => tracks.get(trackId)?._setMuted(muted))
543
+ on("trackEnded", ({ trackId }) => tracks.get(trackId)?._ended())
544
+ on("dataChannel", info => {
541
545
  const channel = new RTCDataChannel(this, info.label, {}, info)
542
546
  this._channels.set(info.id, channel)
543
547
  this._dispatch({ type: "datachannel", channel })
544
548
  })
545
- s.on("dataChannelStateChange", ({ id, state }) => {
549
+ on("dataChannelStateChange", ({ id, state }) => {
546
550
  const channel = this._channels.get(id)
547
551
  if (!channel) return
548
552
  channel._setState(state)
549
553
  if (state === "closed") this._channels.delete(id)
550
554
  })
551
- s.on("dataChannelMessage", ({ id, text, binary }) => this._channels.get(id)?._message(text, binary))
552
- s.on("dataChannelError", ({ id, message }) => this._channels.get(id)?._dispatch({ type: "error", message }))
553
- s.on("dataChannelBufferedAmountLow", ({ id }) => this._channels.get(id)?._dispatch({ type: "bufferedamountlow" }))
555
+ on("dataChannelMessage", ({ id, text, binary }) => this._channels.get(id)?._message(text, binary))
556
+ on("dataChannelError", ({ id, message }) => this._channels.get(id)?._dispatch({ type: "error", message }))
557
+ on("dataChannelBufferedAmountLow", ({ id }) => this._channels.get(id)?._dispatch({ type: "bufferedamountlow" }))
554
558
  }
555
559
 
556
560
  get localDescription(): RTCSessionDescription | null { return this._local }
@@ -654,6 +658,7 @@ export class RTCPeerConnection extends RTCEventTarget {
654
658
  * channel closes. */
655
659
  close(): void {
656
660
  if (this._connection === "closed") return
661
+ this._closedByApp = true
657
662
  this._connection = "closed"
658
663
  this._signaling = "closed"
659
664
  this._ice = "closed"
package/src/version.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // same manifest). Its MAJOR is the bundle ↔ runtime contract: a bundle's `// sdk:` header line
5
5
  // and a host's embedded version must agree on the major for the host to run the bundle; minor
6
6
  // and patch never gate anything (features are detected, never versioned).
7
- export const SDK_VERSION = "2.2.8"
7
+ export const SDK_VERSION = "2.2.9"
8
8
 
9
9
  /** The major of a semver string, or null when it is not one. */
10
10
  export const sdkMajor = (version: string | null | undefined): number | null => {