@defcomm/meetingsdk 0.2.8 → 0.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/dist/index.d.mts CHANGED
@@ -219,7 +219,7 @@ declare class VideoSDKCore {
219
219
  rejectJoinRequest(requestId: string, reason?: string): Promise<void>;
220
220
  toggleMic(): void;
221
221
  toggleCam(): void;
222
- startScreenShare(): Promise<MediaStream>;
222
+ startScreenShare(): Promise<MediaStream | null>;
223
223
  stopScreenShare(): void;
224
224
  startRecording(): Promise<void>;
225
225
  stopRecording(): Promise<void>;
@@ -436,7 +436,7 @@ declare class SFUClient {
436
436
  video?: boolean | undefined;
437
437
  }): Promise<MediaStream>;
438
438
  private publishExistingTracks;
439
- shareScreen(): Promise<MediaStream>;
439
+ shareScreen(): Promise<MediaStream | null>;
440
440
  stopScreenShare(): Promise<void>;
441
441
  muteAudio(muted: boolean): void;
442
442
  muteVideo(muted: boolean): void;
@@ -479,7 +479,7 @@ type MeetingContextValue = {
479
479
  deleteRoom: (roomCode: string) => Promise<any>;
480
480
  toggleMic: () => void;
481
481
  toggleCam: () => void;
482
- startScreenShare: () => Promise<MediaStream>;
482
+ startScreenShare: () => Promise<MediaStream | null>;
483
483
  stopScreenShare: () => void;
484
484
  sendMessage: (input: ChatInput) => void;
485
485
  sendReaction: (emoji: string) => void;
@@ -537,7 +537,7 @@ declare const useMeeting: (handlers?: {
537
537
  deleteRoom: (roomCode: string) => Promise<any>;
538
538
  toggleMic: () => void;
539
539
  toggleCam: () => void;
540
- startScreenShare: () => Promise<MediaStream>;
540
+ startScreenShare: () => Promise<MediaStream | null>;
541
541
  stopScreenShare: () => void;
542
542
  sendMessage: (input: ChatInput) => void;
543
543
  sendReaction: (emoji: string) => void;
package/dist/index.d.ts CHANGED
@@ -219,7 +219,7 @@ declare class VideoSDKCore {
219
219
  rejectJoinRequest(requestId: string, reason?: string): Promise<void>;
220
220
  toggleMic(): void;
221
221
  toggleCam(): void;
222
- startScreenShare(): Promise<MediaStream>;
222
+ startScreenShare(): Promise<MediaStream | null>;
223
223
  stopScreenShare(): void;
224
224
  startRecording(): Promise<void>;
225
225
  stopRecording(): Promise<void>;
@@ -436,7 +436,7 @@ declare class SFUClient {
436
436
  video?: boolean | undefined;
437
437
  }): Promise<MediaStream>;
438
438
  private publishExistingTracks;
439
- shareScreen(): Promise<MediaStream>;
439
+ shareScreen(): Promise<MediaStream | null>;
440
440
  stopScreenShare(): Promise<void>;
441
441
  muteAudio(muted: boolean): void;
442
442
  muteVideo(muted: boolean): void;
@@ -479,7 +479,7 @@ type MeetingContextValue = {
479
479
  deleteRoom: (roomCode: string) => Promise<any>;
480
480
  toggleMic: () => void;
481
481
  toggleCam: () => void;
482
- startScreenShare: () => Promise<MediaStream>;
482
+ startScreenShare: () => Promise<MediaStream | null>;
483
483
  stopScreenShare: () => void;
484
484
  sendMessage: (input: ChatInput) => void;
485
485
  sendReaction: (emoji: string) => void;
@@ -537,7 +537,7 @@ declare const useMeeting: (handlers?: {
537
537
  deleteRoom: (roomCode: string) => Promise<any>;
538
538
  toggleMic: () => void;
539
539
  toggleCam: () => void;
540
- startScreenShare: () => Promise<MediaStream>;
540
+ startScreenShare: () => Promise<MediaStream | null>;
541
541
  stopScreenShare: () => void;
542
542
  sendMessage: (input: ChatInput) => void;
543
543
  sendReaction: (emoji: string) => void;
package/dist/index.js CHANGED
@@ -1461,32 +1461,19 @@ var SFUClient = class {
1461
1461
  }
1462
1462
  }
1463
1463
  async shareScreen() {
1464
- if (!this.publisher) {
1464
+ if (!this.publisher)
1465
1465
  throw new Error("Publisher PeerConnection is not initialized");
1466
- }
1467
- if (!this.screenTransceiver || !this.screenSender) {
1466
+ if (!this.screenTransceiver || !this.screenSender)
1468
1467
  throw new Error("Screen transceiver is not initialized");
1469
- }
1468
+ const existing = this.screenStream;
1470
1469
  const existingTrack = this.screenSender.track;
1471
- if (this.screenStream && existingTrack && existingTrack.readyState === "live") {
1472
- return this.screenStream;
1470
+ if (existing || existingTrack && existingTrack.readyState === "live") {
1471
+ return existing;
1473
1472
  }
1474
- const generation = ++this.screenShareGeneration;
1475
1473
  try {
1476
1474
  await this.screenSender.replaceTrack(null);
1477
- } catch (err) {
1478
- console.warn("[SFU] Failed to clear previous screen track", err);
1479
- }
1480
- if (this.screenStream) {
1481
- for (const track of this.screenStream.getTracks()) {
1482
- try {
1483
- track.onended = null;
1484
- track.stop();
1485
- } catch {
1486
- }
1487
- }
1475
+ } catch {
1488
1476
  }
1489
- this.screenStream = null;
1490
1477
  this.screenTransceiver.direction = "inactive";
1491
1478
  const screenStream = await navigator.mediaDevices.getDisplayMedia({
1492
1479
  video: true,
@@ -1497,58 +1484,34 @@ var SFUClient = class {
1497
1484
  screenStream.getTracks().forEach((track) => track.stop());
1498
1485
  throw new Error("Screen share returned no video track");
1499
1486
  }
1487
+ const generation = ++this.screenShareGeneration;
1500
1488
  this.screenStream = screenStream;
1501
1489
  try {
1502
1490
  await this.screenSender.replaceTrack(screenTrack);
1503
1491
  this.screenTransceiver.direction = "sendonly";
1504
- this.send({
1505
- type: "start_screen_share"
1506
- });
1507
- await new Promise((resolve) => {
1508
- queueMicrotask(resolve);
1509
- });
1492
+ this.send({ type: "start_screen_share" });
1510
1493
  const offer = await this.publisher.createOffer();
1511
1494
  await this.publisher.setLocalDescription(offer);
1512
- const localDescription = this.publisher.localDescription;
1513
- if (!localDescription?.sdp) {
1514
- throw new Error("Publisher did not produce a valid screen-share SDP");
1515
- }
1516
- const revision = ++this.publisherRevision;
1517
1495
  this.send({
1518
1496
  type: "publish_offer",
1519
- payload: {
1520
- revision,
1521
- sdp: localDescription.sdp
1522
- }
1497
+ payload: { revision: ++this.publisherRevision, sdp: offer.sdp }
1523
1498
  });
1524
1499
  screenTrack.onended = () => {
1525
- if (generation !== this.screenShareGeneration) {
1526
- return;
1527
- }
1500
+ if (generation !== this.screenShareGeneration) return;
1528
1501
  void this.stopScreenShare();
1529
1502
  };
1530
- return screenStream;
1503
+ return this.screenStream;
1531
1504
  } catch (error) {
1532
- if (generation === this.screenShareGeneration) {
1533
- try {
1534
- await this.screenSender.replaceTrack(null);
1535
- } catch {
1536
- }
1537
- this.screenTransceiver.direction = "inactive";
1538
- screenTrack.onended = null;
1539
- screenStream.getTracks().forEach((track) => {
1540
- try {
1541
- track.stop();
1542
- } catch {
1543
- }
1544
- });
1545
- this.screenStream = null;
1546
- try {
1547
- this.send({
1548
- type: "stop_screen_share"
1549
- });
1550
- } catch {
1551
- }
1505
+ try {
1506
+ await this.screenSender.replaceTrack(null);
1507
+ } catch {
1508
+ }
1509
+ this.screenTransceiver.direction = "inactive";
1510
+ screenStream.getTracks().forEach((track) => track.stop());
1511
+ this.screenStream = null;
1512
+ try {
1513
+ this.send({ type: "stop_screen_share" });
1514
+ } catch {
1552
1515
  }
1553
1516
  throw error;
1554
1517
  }
@@ -1687,7 +1650,9 @@ var SFUClient = class {
1687
1650
  sendReaction(reaction) {
1688
1651
  this.send({
1689
1652
  type: "send_reaction",
1690
- reaction
1653
+ payload: {
1654
+ reaction
1655
+ }
1691
1656
  });
1692
1657
  }
1693
1658
  removeRemoteParticipant(participantId) {