@poolse/react 3.2.0-dev.1 → 3.2.0-dev.3

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.cts CHANGED
@@ -540,6 +540,19 @@ interface UseCallRoom {
540
540
  participants: CallParticipant[];
541
541
  cameraEnabled: boolean;
542
542
  micEnabled: boolean;
543
+ /** You are sharing a screen or window. */
544
+ screenSharing: boolean;
545
+ /**
546
+ * Whoever is sharing a screen right now (you included), or null. When
547
+ * several share at once, the first in the roster.
548
+ */
549
+ sharingParticipant: CallParticipant | null;
550
+ /**
551
+ * Whether this platform can share a screen: a desktop browser, or a
552
+ * native build with screen capture. Phone browsers cannot. Also hide
553
+ * the control when the call's `screen_share_allowed` is false.
554
+ */
555
+ canShareScreen: boolean;
543
556
  /** Which camera is publishing. Meaningless while the camera is off. */
544
557
  facingMode: CameraFacing;
545
558
  /**
@@ -598,6 +611,9 @@ interface UseCallRoom {
598
611
  switchCamera: () => Promise<void>;
599
612
  setMicrophoneEnabled: (enabled: boolean) => Promise<void>;
600
613
  toggleMic: () => Promise<void>;
614
+ /** Share a screen (the platform's picker opens) or stop sharing. */
615
+ setScreenShareEnabled: (enabled: boolean) => Promise<void>;
616
+ toggleScreenShare: () => Promise<void>;
601
617
  }
602
618
  /**
603
619
  * A call's media, carried by the SFU.
@@ -610,8 +626,8 @@ interface UseCallRoom {
610
626
  * await media.join();
611
627
  * await media.toggleCamera();
612
628
  *
613
- * Both the camera and the microphone can be turned on and off at any
614
- * point during the call.
629
+ * The camera, the microphone and screen sharing can each be turned on
630
+ * and off at any point during the call.
615
631
  */
616
632
  declare function useCallRoom(conversationId: string | null, opts: UseCallRoomOptions): UseCallRoom;
617
633
 
package/dist/index.d.ts CHANGED
@@ -540,6 +540,19 @@ interface UseCallRoom {
540
540
  participants: CallParticipant[];
541
541
  cameraEnabled: boolean;
542
542
  micEnabled: boolean;
543
+ /** You are sharing a screen or window. */
544
+ screenSharing: boolean;
545
+ /**
546
+ * Whoever is sharing a screen right now (you included), or null. When
547
+ * several share at once, the first in the roster.
548
+ */
549
+ sharingParticipant: CallParticipant | null;
550
+ /**
551
+ * Whether this platform can share a screen: a desktop browser, or a
552
+ * native build with screen capture. Phone browsers cannot. Also hide
553
+ * the control when the call's `screen_share_allowed` is false.
554
+ */
555
+ canShareScreen: boolean;
543
556
  /** Which camera is publishing. Meaningless while the camera is off. */
544
557
  facingMode: CameraFacing;
545
558
  /**
@@ -598,6 +611,9 @@ interface UseCallRoom {
598
611
  switchCamera: () => Promise<void>;
599
612
  setMicrophoneEnabled: (enabled: boolean) => Promise<void>;
600
613
  toggleMic: () => Promise<void>;
614
+ /** Share a screen (the platform's picker opens) or stop sharing. */
615
+ setScreenShareEnabled: (enabled: boolean) => Promise<void>;
616
+ toggleScreenShare: () => Promise<void>;
601
617
  }
602
618
  /**
603
619
  * A call's media, carried by the SFU.
@@ -610,8 +626,8 @@ interface UseCallRoom {
610
626
  * await media.join();
611
627
  * await media.toggleCamera();
612
628
  *
613
- * Both the camera and the microphone can be turned on and off at any
614
- * point during the call.
629
+ * The camera, the microphone and screen sharing can each be turned on
630
+ * and off at any point during the call.
615
631
  */
616
632
  declare function useCallRoom(conversationId: string | null, opts: UseCallRoomOptions): UseCallRoom;
617
633
 
package/dist/index.js CHANGED
@@ -1160,6 +1160,8 @@ function useCallRoom(conversationId, opts) {
1160
1160
  const [participants, setParticipants] = useState([]);
1161
1161
  const [cameraEnabled, setCamera] = useState(false);
1162
1162
  const [micEnabled, setMic] = useState(false);
1163
+ const [screenSharing, setScreen] = useState(false);
1164
+ const [canShareScreen, setCanShare] = useState(false);
1163
1165
  const [facingMode, setFacing] = useState(opts.facing ?? "user");
1164
1166
  const [alone, setAlone] = useState(false);
1165
1167
  const [devices, setDevices] = useState({
@@ -1203,6 +1205,8 @@ function useCallRoom(conversationId, opts) {
1203
1205
  if (!target) return;
1204
1206
  setCamera(target.isCameraEnabled());
1205
1207
  setMic(target.isMicrophoneEnabled());
1208
+ setScreen(target.isScreenShareEnabled());
1209
+ setCanShare(target.canShareScreen());
1206
1210
  setFacing(target.getFacingMode());
1207
1211
  }, []);
1208
1212
  useEffect(() => {
@@ -1286,6 +1290,22 @@ function useCallRoom(conversationId, opts) {
1286
1290
  if (!room) return;
1287
1291
  await setMicrophoneEnabled(!room.isMicrophoneEnabled());
1288
1292
  }, [room, setMicrophoneEnabled]);
1293
+ const setScreenShareEnabled = useCallback(
1294
+ async (enabled) => {
1295
+ if (!room) return;
1296
+ await room.setScreenShareEnabled(enabled);
1297
+ sync(room);
1298
+ },
1299
+ [room, sync]
1300
+ );
1301
+ const toggleScreenShare = useCallback(async () => {
1302
+ if (!room) return;
1303
+ await setScreenShareEnabled(!room.isScreenShareEnabled());
1304
+ }, [room, setScreenShareEnabled]);
1305
+ const sharingParticipant = useMemo(
1306
+ () => participants.find((p) => p.screenSharing) ?? null,
1307
+ [participants]
1308
+ );
1289
1309
  const switchCamera = useCallback(async () => {
1290
1310
  if (!room) return;
1291
1311
  await room.switchCamera();
@@ -1310,6 +1330,9 @@ function useCallRoom(conversationId, opts) {
1310
1330
  participants,
1311
1331
  cameraEnabled,
1312
1332
  micEnabled,
1333
+ screenSharing,
1334
+ sharingParticipant,
1335
+ canShareScreen,
1313
1336
  facingMode,
1314
1337
  alone,
1315
1338
  devices,
@@ -1324,7 +1347,9 @@ function useCallRoom(conversationId, opts) {
1324
1347
  switchCamera,
1325
1348
  selectDevice,
1326
1349
  setMicrophoneEnabled,
1327
- toggleMic
1350
+ toggleMic,
1351
+ setScreenShareEnabled,
1352
+ toggleScreenShare
1328
1353
  };
1329
1354
  }
1330
1355
  function useLiveCall(conversationId) {